Added mermaid test cases for sequence diagrams

This commit is contained in:
Bartek Kryza
2023-09-12 23:04:54 +02:00
parent 59180efebf
commit 57af380dfa
39 changed files with 1224 additions and 528 deletions

View File

@@ -29,35 +29,35 @@ TEST_CASE("t20004", "[test-case][sequence]")
REQUIRE(model->name() == "t20004_sequence");
{
auto puml = generate_sequence_puml(diagram, *model);
AliasMatcher _A(puml);
auto src = generate_sequence_puml(diagram, *model);
AliasMatcher _A(src);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(src, StartsWith("@startuml"));
REQUIRE_THAT(src, HasCall(_A("main()"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(
puml, !HasCall(_A("m1<float>(float)"), _A("m1<float>(float)"), ""));
src, !HasCall(_A("m1<float>(float)"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(
puml, !HasCall(_A("m1<float>(float)"), _A("m1<float>(float)"), ""));
src, !HasCall(_A("m1<float>(float)"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(puml,
REQUIRE_THAT(src,
HasCall(_A("main()"), _A("m1<unsigned long>(unsigned long)"), ""));
REQUIRE_THAT(puml,
REQUIRE_THAT(src,
HasCall(_A("m1<unsigned long>(unsigned long)"),
_A("m4<unsigned long>(unsigned long)"), ""));
REQUIRE_THAT(puml,
HasCall(_A("main()"), _A("m1<std::string>(std::string)"), ""));
REQUIRE_THAT(puml,
REQUIRE_THAT(
src, HasCall(_A("main()"), _A("m1<std::string>(std::string)"), ""));
REQUIRE_THAT(src,
HasCall(_A("m1<std::string>(std::string)"),
_A("m2<std::string>(std::string)"), ""));
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<int>(int)"), ""));
REQUIRE_THAT(puml, HasCall(_A("m1<int>(int)"), _A("m2<int>(int)"), ""));
REQUIRE_THAT(puml, HasCall(_A("m2<int>(int)"), _A("m3<int>(int)"), ""));
REQUIRE_THAT(puml, HasCall(_A("m3<int>(int)"), _A("m4<int>(int)"), ""));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(src, HasCall(_A("main()"), _A("m1<int>(int)"), ""));
REQUIRE_THAT(src, HasCall(_A("m1<int>(int)"), _A("m2<int>(int)"), ""));
REQUIRE_THAT(src, HasCall(_A("m2<int>(int)"), _A("m3<int>(int)"), ""));
REQUIRE_THAT(src, HasCall(_A("m3<int>(int)"), _A("m4<int>(int)"), ""));
REQUIRE_THAT(src, EndsWith("@enduml\n"));
save_puml(config.output_directory(), diagram->name + ".puml", puml);
save_puml(config.output_directory(), diagram->name + ".puml", src);
}
{
@@ -84,8 +84,34 @@ TEST_CASE("t20004", "[test-case][sequence]")
}
{
auto mmd = generate_sequence_mermaid(diagram, *model);
auto src = generate_sequence_mermaid(diagram, *model);
save_mermaid(config.output_directory(), diagram->name + ".mmd", mmd);
mermaid::SequenceDiagramAliasMatcher _A(src);
using mermaid::HasCall;
REQUIRE_THAT(src, HasCall(_A("main()"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(
src, !HasCall(_A("m1<float>(float)"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(
src, !HasCall(_A("m1<float>(float)"), _A("m1<float>(float)"), ""));
REQUIRE_THAT(src,
HasCall(_A("main()"), _A("m1<unsigned long>(unsigned long)"), ""));
REQUIRE_THAT(src,
HasCall(_A("m1<unsigned long>(unsigned long)"),
_A("m4<unsigned long>(unsigned long)"), ""));
REQUIRE_THAT(
src, HasCall(_A("main()"), _A("m1<std::string>(std::string)"), ""));
REQUIRE_THAT(src,
HasCall(_A("m1<std::string>(std::string)"),
_A("m2<std::string>(std::string)"), ""));
REQUIRE_THAT(src, HasCall(_A("main()"), _A("m1<int>(int)"), ""));
REQUIRE_THAT(src, HasCall(_A("m1<int>(int)"), _A("m2<int>(int)"), ""));
REQUIRE_THAT(src, HasCall(_A("m2<int>(int)"), _A("m3<int>(int)"), ""));
REQUIRE_THAT(src, HasCall(_A("m3<int>(int)"), _A("m4<int>(int)"), ""));
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
}
}