Added mermaid test cases for class diagrams

This commit is contained in:
Bartek Kryza
2023-09-12 00:55:05 +02:00
parent de5625a474
commit eb00cd21c3
71 changed files with 3189 additions and 1295 deletions

View File

@@ -29,34 +29,34 @@ TEST_CASE("t00027", "[test-case][class]")
REQUIRE(model->name() == "t00027_class");
{
auto puml = generate_class_puml(diagram, *model);
AliasMatcher _A(puml);
auto src = generate_class_puml(diagram, *model);
AliasMatcher _A(src);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, IsAbstractClass(_A("Shape")));
REQUIRE_THAT(puml, IsAbstractClass(_A("ShapeDecorator")));
REQUIRE_THAT(puml, IsClassTemplate("Line", "T<>..."));
REQUIRE_THAT(puml, IsClassTemplate("Text", "T<>..."));
REQUIRE_THAT(src, StartsWith("@startuml"));
REQUIRE_THAT(src, EndsWith("@enduml\n"));
REQUIRE_THAT(src, IsAbstractClass(_A("Shape")));
REQUIRE_THAT(src, IsAbstractClass(_A("ShapeDecorator")));
REQUIRE_THAT(src, IsClassTemplate("Line", "T<>..."));
REQUIRE_THAT(src, IsClassTemplate("Text", "T<>..."));
REQUIRE_THAT(
puml, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color>")));
REQUIRE_THAT(puml,
IsInstantiation(_A("Line<T<>...>"), _A("Line<Color,Weight>")));
src, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color>")));
REQUIRE_THAT(puml,
IsInstantiation(_A("Text<T<>...>"), _A("Text<Color,Weight>")));
src, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color,Weight>")));
REQUIRE_THAT(
src, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color>")));
REQUIRE_THAT(
src, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color,Weight>")));
REQUIRE_THAT(puml,
REQUIRE_THAT(src,
IsAggregation(_A("Window"), _A("Line<Color,Weight>"), "+border"));
REQUIRE_THAT(
puml, IsAggregation(_A("Window"), _A("Line<Color>"), "+divider"));
REQUIRE_THAT(puml,
src, IsAggregation(_A("Window"), _A("Line<Color>"), "+divider"));
REQUIRE_THAT(src,
IsAggregation(_A("Window"), _A("Text<Color,Weight>"), "+title"));
REQUIRE_THAT(puml,
REQUIRE_THAT(src,
IsAggregation(_A("Window"), _A("Text<Color>"), "+description"));
save_puml(config.output_directory(), diagram->name + ".puml", puml);
save_puml(config.output_directory(), diagram->name + ".puml", src);
}
{
auto j = generate_class_json(diagram, *model);
@@ -77,8 +77,33 @@ TEST_CASE("t00027", "[test-case][class]")
save_json(config.output_directory(), diagram->name + ".json", j);
}
{
auto mmd = generate_class_mermaid(diagram, *model);
auto src = generate_class_mermaid(diagram, *model);
save_mermaid(config.output_directory(), diagram->name + ".mmd", mmd);
mermaid::AliasMatcher _A(src);
using mermaid::IsAbstractClass;
REQUIRE_THAT(src, IsAbstractClass(_A("Shape")));
REQUIRE_THAT(src, IsAbstractClass(_A("ShapeDecorator")));
REQUIRE_THAT(src, IsClass(_A("Line<T<>...>")));
REQUIRE_THAT(src, IsClass(_A("Text<T<>...>")));
REQUIRE_THAT(
src, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color>")));
REQUIRE_THAT(
src, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color,Weight>")));
REQUIRE_THAT(
src, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color>")));
REQUIRE_THAT(
src, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color,Weight>")));
REQUIRE_THAT(src,
IsAggregation(_A("Window"), _A("Line<Color,Weight>"), "+border"));
REQUIRE_THAT(
src, IsAggregation(_A("Window"), _A("Line<Color>"), "+divider"));
REQUIRE_THAT(src,
IsAggregation(_A("Window"), _A("Text<Color,Weight>"), "+title"));
REQUIRE_THAT(src,
IsAggregation(_A("Window"), _A("Text<Color>"), "+description"));
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
}
}