1.8 KiB
1.8 KiB
t20020 - If statement sequence diagram test case
Config
compilation_database_dir: ..
output_directory: puml
diagrams:
t20020_sequence:
type: sequence
glob:
- ../../tests/t20020/t20020.cc
include:
namespaces:
- clanguml::t20020
using_namespace:
- clanguml::t20020
start_from:
- function: "clanguml::t20020::tmain()"
Source code
File t20020.cc
#include <cmath>
#include <cstdint>
namespace clanguml {
namespace t20020 {
struct A {
int a1() { return 0; }
int a2() { return 1; }
int a3() { return 2; }
};
struct B {
void log() { }
int b1() { return 3; }
int b2() { return 4; }
};
struct C {
void log() const { }
void c1() const
{
if (c2())
log();
}
bool c2() const { return true; }
};
template <typename T> struct D {
T d1(T x, T y) { return x + y; }
};
int tmain()
{
A a;
B b;
C c;
D<int> d;
int result{0};
if (reinterpret_cast<uint64_t>(&a) % 100 == 0ULL) {
result = a.a1();
}
else if (reinterpret_cast<uint64_t>(&a) % 64 == 0ULL) {
if (a.a2() > 2)
result = b.b1();
else
result = b.b2();
}
else {
result = a.a3();
}
b.log();
if (true)
c.c1();
if (true)
d.d1(1, 1);
// This if/else should not be included in the diagram at all
// as the calls to std will be excluded by the diagram filters
if (result != 2) {
result = std::exp(result);
}
else if (result == 3) {
result = 4;
}
else {
result = std::exp(result + 1);
}
return result;
}
}
}