Added start_from function and method entrypoints in sequence diagrams

This commit is contained in:
Bartek Kryza
2022-12-09 22:12:24 +01:00
parent caf0ae7928
commit 69ca8c2d8e
8 changed files with 179 additions and 87 deletions

View File

@@ -35,9 +35,10 @@ TEST_CASE("t20005", "[test-case][sequence]")
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all calls exist
REQUIRE_THAT(puml, HasEntrypoint(_A("C<T>"), "c(T)"));
REQUIRE_THAT(puml, HasCall(_A("C<T>"), _A("B<T>"), "b(T)"));
REQUIRE_THAT(puml, HasCall(_A("B<T>"), _A("A<T>"), "a(T)"));
REQUIRE_THAT(puml, HasExitpoint(_A("C<T>")));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
}

View File

@@ -35,16 +35,19 @@ TEST_CASE("t20017", "[test-case][sequence]")
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all calls exist
REQUIRE_THAT(puml, HasEntrypoint(_A("t20017.cc"), "tmain()"));
REQUIRE_THAT(puml,
HasCall(_A("t20017.cc"), _A("include/t20017_a.h"), "a1(int,int)"));
REQUIRE_THAT(
puml, HasCall(_A("t20017.cc"), _A("include/t20017_a.h"), "a2(int,int)"));
REQUIRE_THAT(puml,
HasCall(_A("t20017.cc"), _A("include/t20017_a.h"), "a2(int,int)"));
REQUIRE_THAT(puml,
HasCall(_A("t20017.cc"), _A("include/t20017_a.h"), "a3(int,int)"));
REQUIRE_THAT(puml,
HasCall(_A("t20017.cc"), _A("include/t20017_b.h"), "b1(int,int)"));
REQUIRE_THAT(puml,
HasCall(_A("t20017.cc"), _A("include/t20017_b.h"), "b2<int>(int,int)"));
HasCall(
_A("t20017.cc"), _A("include/t20017_b.h"), "b2<int>(int,int)"));
REQUIRE_THAT(puml, HasExitpoint(_A("t20017.cc")));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);

View File

@@ -310,4 +310,4 @@ int main(int argc, char *argv[])
clanguml::util::setup_logging(debug_log);
return session.run();
}
}

View File

@@ -79,26 +79,19 @@ template <typename T, typename... Ts> constexpr bool has_type() noexcept
return (std::is_same_v<T, Ts> || ... || false);
}
struct Public {
};
struct Public { };
struct Protected {
};
struct Protected { };
struct Private {
};
struct Private { };
struct Abstract {
};
struct Abstract { };
struct Static {
};
struct Static { };
struct Const {
};
struct Const { };
struct Default {
};
struct Default { };
struct HasCallWithResultMatcher : ContainsMatcher {
HasCallWithResultMatcher(
@@ -144,6 +137,20 @@ auto HasCallWithResponse(std::string const &from, std::string const &to,
CasedString(fmt::format("{} --> {}", to, from), caseSensitivity));
}
ContainsMatcher HasEntrypoint(std::string const &to, std::string const &message,
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
{
return ContainsMatcher(
CasedString(fmt::format("[-> {} : {}", to, message), caseSensitivity));
}
ContainsMatcher HasExitpoint(std::string const &to,
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
{
return ContainsMatcher(
CasedString(fmt::format("[<-- {}", to), caseSensitivity));
}
struct AliasMatcher {
AliasMatcher(const std::string &puml_)
: puml{split(puml_, "\n")}