81 lines
1.5 KiB
Markdown
81 lines
1.5 KiB
Markdown
# t20020 - If statement sequence diagram test case
|
|
## Config
|
|
```yaml
|
|
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
|
|
```cpp
|
|
#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; }
|
|
};
|
|
|
|
int tmain()
|
|
{
|
|
A a;
|
|
B b;
|
|
|
|
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();
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
## Generated UML diagrams
|
|

|