Added basic test case for sequence diagrams with class template specializations
This commit is contained in:
@@ -32,27 +32,24 @@ TEST_CASE("t20004", "[test-case][sequence]")
|
||||
AliasMatcher _A(puml);
|
||||
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<float>()"), "m1<float>"));
|
||||
REQUIRE_THAT(puml, !HasCall(_A("m1<float>()"), _A("m1<float>()"), "m2<T>"));
|
||||
REQUIRE_THAT(
|
||||
puml, !HasCall(_A("m1<float>()"), _A("m1<float>()"), "m2<float>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<float>()"), "m1"));
|
||||
REQUIRE_THAT(puml, !HasCall(_A("m1<float>()"), _A("m1<float>()"), "m2"));
|
||||
REQUIRE_THAT(puml, !HasCall(_A("m1<float>()"), _A("m1<float>()"), "m2"));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
HasCall(_A("main()"), _A("m1<unsigned long>()"), "m1<unsigned long>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<unsigned long>()"), "m1"));
|
||||
REQUIRE_THAT(puml,
|
||||
HasCall(_A("m1<unsigned long>()"), _A("m4<unsigned long>()"),
|
||||
"m4<unsigned long>"));
|
||||
"m4"));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
HasCall(_A("main()"), _A("m1<std::string>()"), "m1<std::string>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<std::string>()"), "m1"));
|
||||
REQUIRE_THAT(puml,
|
||||
HasCall(_A("m1<std::string>()"), _A("m2<std::string>()"),
|
||||
"m2<std::string>"));
|
||||
"m2"));
|
||||
|
||||
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<T>()"), "m1<int>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("m1<T>()"), _A("m2<T>()"), "m2<T>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("m2<T>()"), _A("m3<T>()"), "m3<T>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("m3<T>()"), _A("m4<T>()"), "m4<T>"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<int>()"), "m1"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("m1<int>()"), _A("m2<int>()"), "m2"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("m2<int>()"), _A("m3<int>()"), "m3"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("m3<int>()"), _A("m4<int>()"), "m4"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
|
||||
save_puml(
|
||||
|
||||
@@ -4,20 +4,41 @@ namespace clanguml {
|
||||
namespace t20006 {
|
||||
|
||||
template <typename T> struct A {
|
||||
T a_int(T arg) { return arg + 1; }
|
||||
T a_string(T arg) { return arg + "_string"; }
|
||||
T a1(T arg) { return arg; }
|
||||
T a2(T arg) { return arg + arg; }
|
||||
};
|
||||
|
||||
template <typename T> struct B {
|
||||
T b(T arg) { return a_.a_int(arg); }
|
||||
T b(T arg) { return a_.a1(arg); }
|
||||
A<T> a_;
|
||||
};
|
||||
|
||||
template <> struct B<std::string> {
|
||||
std::string b(std::string arg) { return a_.a_string(arg); }
|
||||
std::string b(std::string arg) { return a_.a2(arg); }
|
||||
A<std::string> a_;
|
||||
};
|
||||
|
||||
template <typename T> struct AA {
|
||||
void aa1(T t) { }
|
||||
void aa2(T t) { }
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename F> struct BB {
|
||||
void bb1(T t, F f) { aa_.aa1(t); }
|
||||
void bb2(T t, F f) { aa_.aa2(t); }
|
||||
|
||||
AA<T> aa_;
|
||||
};
|
||||
|
||||
template <typename T> struct BB<T, std::string> {
|
||||
void bb1(T t, std::string f) { aa_.aa2(t); }
|
||||
void bb2(T t, std::string f) { aa_.aa1(t); }
|
||||
|
||||
AA<T> aa_;
|
||||
};
|
||||
|
||||
|
||||
void tmain()
|
||||
{
|
||||
B<int> bint;
|
||||
@@ -25,6 +46,15 @@ void tmain()
|
||||
|
||||
bint.b(1);
|
||||
bstring.b("bstring");
|
||||
|
||||
BB<int, int> bbint;
|
||||
BB<int, std::string> bbstring;
|
||||
|
||||
bbint.bb1(1, 1);
|
||||
bbint.bb2(2, 2);
|
||||
|
||||
bbstring.bb1(1, "calling aa2");
|
||||
bbstring.bb2(1, "calling aa1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,12 +35,28 @@ 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<T>"), "B<int>::b"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("B<T>"), _A("A<T>"), "a_int"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B<int>"), "b"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("B<int>"), _A("A<int>"), "a1"));
|
||||
|
||||
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("B<std::string>"), "b"));
|
||||
REQUIRE_THAT(puml,
|
||||
HasCall(_A("B<std::string>"), _A("A<T>"), "A<std::string>::a_string"));
|
||||
REQUIRE_THAT(
|
||||
puml, HasCall(_A("B<std::string>"), _A("A<std::string>"), "a2"));
|
||||
|
||||
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("BB<int,int>"), "bb1"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("BB<int,int>"), _A("AA<int>"), "aa1"));
|
||||
|
||||
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("BB<int,int>"), "bb2"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("BB<int,int>"), _A("AA<int>"), "aa2"));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, HasCall(_A("tmain()"), _A("BB<int,std::string>"), "bb1"));
|
||||
REQUIRE_THAT(
|
||||
puml, HasCall(_A("BB<int,std::string>"), _A("AA<int>"), "aa2"));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, HasCall(_A("tmain()"), _A("BB<int,std::string>"), "bb2"));
|
||||
REQUIRE_THAT(
|
||||
puml, HasCall(_A("BB<int,std::string>"), _A("AA<int>"), "aa1"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
Reference in New Issue
Block a user