Added highlight of calls within condition statements of if/else blocks

This commit is contained in:
Bartek Kryza
2022-12-12 21:07:28 +01:00
parent b2396d7b44
commit d7c13edbf9
10 changed files with 93 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ struct A {
int a1() { return 0; }
int a2() { return 1; }
int a3() { return 2; }
int a4() { return 3; }
};
struct B {
@@ -26,6 +27,8 @@ struct C {
}
bool c2() const { return true; }
int c3(int x) { return x * 2; }
};
template <typename T> struct D {
@@ -46,13 +49,15 @@ int tmain()
result = a.a1();
}
else if (reinterpret_cast<uint64_t>(&a) % 64 == 0ULL) {
if (a.a2() > 2)
if (c.c3(a.a2()) > 2)
result = b.b1();
else
else if (a.a3() % 2)
result = b.b2();
else
result = 0;
}
else {
result = a.a3();
result = a.a4();
}
b.log();

View File

@@ -36,14 +36,19 @@ TEST_CASE("t20020", "[test-case][sequence]")
// Check if all calls exist
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("A"), "a1()"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("A"), "a2()"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("A"), "a3()"));
REQUIRE_THAT(
puml, HasCallInControlCondition(_A("tmain()"), _A("A"), "a2()"));
REQUIRE_THAT(
puml, HasCallInControlCondition(_A("tmain()"), _A("A"), "a3()"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B"), "b1()"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B"), "b2()"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B"), "log()"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("C"), "c1()"));
REQUIRE_THAT(puml, HasCallInControlCondition(_A("C"), _A("C"), "c2()"));
REQUIRE_THAT(
puml, HasCallInControlCondition(_A("tmain()"), _A("C"), "c3(int)"));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);