Added highlight of calls within condition statements of if/else blocks
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -132,8 +132,10 @@ public:
|
||||
, m_message{message}
|
||||
{
|
||||
util::replace_all(m_message, "(", "\\(");
|
||||
util::replace_all(m_message, "*", "\\*");
|
||||
util::replace_all(m_message, ")", "\\)");
|
||||
util::replace_all(m_message, "*", "\\*");
|
||||
util::replace_all(m_message, "[", "\\[");
|
||||
util::replace_all(m_message, "]", "\\]");
|
||||
}
|
||||
|
||||
bool match(T const &in) const override
|
||||
@@ -169,6 +171,13 @@ auto HasCall(std::string const &from, std::string const &to,
|
||||
return HasCallMatcher(from, to, message);
|
||||
}
|
||||
|
||||
auto HasCallInControlCondition(std::string const &from, std::string const &to,
|
||||
std::string const &message,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
return HasCallMatcher(from, to, fmt::format("**[**{}**]**", message));
|
||||
}
|
||||
|
||||
auto HasCall(std::string const &from, std::string const &message,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user