Added basic test case for sequence diagrams with template specializations

This commit is contained in:
Bartek Kryza
2022-11-23 00:05:43 +01:00
parent 4513e17275
commit b264ef5402
6 changed files with 144 additions and 43 deletions

View File

@@ -4,17 +4,17 @@ namespace clanguml {
namespace t20006 {
template <typename T> struct A {
T a(T arg) { return arg; }
T a1(T arg) { return arg; }
T a_int(T arg) { return arg + 1; }
T a_string(T arg) { return arg + "_string"; }
};
template <typename T> struct B {
T b(T arg) { return a_.a(arg); }
T b(T arg) { return a_.a_int(arg); }
A<T> a_;
};
template <> struct B<std::string> {
std::string b(std::string arg) { return arg; }
std::string b(std::string arg) { return a_.a_string(arg); }
A<std::string> a_;
};

View File

@@ -35,12 +35,12 @@ TEST_CASE("t20006", "[test-case][sequence]")
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all calls exist
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B<int>"), "b"));
REQUIRE_THAT(puml, HasCall(_A("B<int>"), _A("A<int>"), "a"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B<T>"), "B<int>::b"));
REQUIRE_THAT(puml, HasCall(_A("B<T>"), _A("A<T>"), "a_int"));
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B<std::string>"), "b"));
REQUIRE_THAT(
puml, !HasCall(_A("B<std::string>"), _A("A<std::string>"), "a"));
REQUIRE_THAT(puml,
HasCall(_A("B<std::string>"), _A("A<T>"), "A<std::string>::a_string"));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);