Implemented tests for concept test case 00056

This commit is contained in:
Bartek Kryza
2023-02-26 13:51:25 +01:00
parent 1fc0bf3f80
commit 3509853dba
7 changed files with 132 additions and 67 deletions

View File

@@ -35,32 +35,59 @@ TEST_CASE("t00056", "[test-case][class]")
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all classes exist
// REQUIRE_THAT(puml, IsClass(_A("A")));
REQUIRE_THAT(puml, IsConcept(_A("greater_than_simple<T,L>")));
REQUIRE_THAT(puml, IsConcept(_A("greater_than_with_requires<T,P>")));
REQUIRE_THAT(puml, IsConcept(_A("max_four_bytes<T>")));
REQUIRE_THAT(puml, IsConcept(_A("iterable<T>")));
REQUIRE_THAT(puml, IsConcept(_A("has_value_type<T>")));
REQUIRE_THAT(puml, IsConcept(_A("convertible_to_string<T>")));
REQUIRE_THAT(puml, IsConcept(_A("iterable_with_value_type<T>")));
REQUIRE_THAT(puml, IsConcept(_A("iterable_or_small_value_type<T>")));
// Check if class templates exist
// REQUIRE_THAT(puml, IsClassTemplate("A", "T,P,CMP,int N"));
// Check if all enums exist
// REQUIRE_THAT(puml, IsEnum(_A("Lights")));
// Check if all inner classes exist
// REQUIRE_THAT(puml, IsInnerClass(_A("A"), _A("AA")));
// Check if all inheritance relationships exist
// REQUIRE_THAT(puml, IsBaseClass(_A("Base"), _A("Child")));
// Check if all methods exist
// REQUIRE_THAT(puml, (IsMethod<Public, Const>("foo")));
// Check if all fields exist
// REQUIRE_THAT(puml, (IsField<Private>("private_member", "int")));
REQUIRE_THAT(puml, IsClassTemplate("A", "max_four_bytes T"));
REQUIRE_THAT(puml, IsClassTemplate("B", "T"));
REQUIRE_THAT(puml, IsClassTemplate("C", "convertible_to_string T"));
REQUIRE_THAT(
puml, IsClassTemplate("D", "iterable T1,T2,iterable T3,T4,T5"));
REQUIRE_THAT(puml, IsClassTemplate("E", "T1,T2,T3"));
REQUIRE_THAT(puml, IsClassTemplate("F", "T1,T2,T3"));
// Check if all relationships exist
// REQUIRE_THAT(puml, IsAssociation(_A("D"), _A("A"), "-as"));
// REQUIRE_THAT(puml, IsDependency(_A("R"), _A("B")));
// REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("D")));
// REQUIRE_THAT(puml, IsComposition(_A("R"), _A("D")));
// REQUIRE_THAT(puml, IsInstantiation(_A("ABCD::F<T>"), _A("F<int>")));
REQUIRE_THAT(puml,
IsConstraint(_A("A<max_four_bytes T>"), _A("max_four_bytes<T>"), "T"));
REQUIRE_THAT(puml,
IsConstraint(_A("D<iterable T1,T2,iterable T3,T4,T5>"),
_A("max_four_bytes<T>"), "T2"));
REQUIRE_THAT(puml,
IsConstraint(_A("D<iterable T1,T2,iterable T3,T4,T5>"),
_A("max_four_bytes<T>"), "T5"));
REQUIRE_THAT(puml,
IsConstraint(_A("D<iterable T1,T2,iterable T3,T4,T5>"),
_A("iterable<T>"), "T1"));
REQUIRE_THAT(puml,
IsConstraint(_A("D<iterable T1,T2,iterable T3,T4,T5>"),
_A("iterable<T>"), "T3"));
REQUIRE_THAT(puml,
IsConstraint(
_A("iterable_with_value_type<T>"), _A("has_value_type<T>"), "T"));
REQUIRE_THAT(puml,
IsConstraint(_A("iterable_or_small_value_type<T>"),
_A("max_four_bytes<T>"), "T"));
REQUIRE_THAT(puml,
IsConstraint(_A("iterable_or_small_value_type<T>"),
_A("iterable_with_value_type<T>"), "T"));
REQUIRE_THAT(puml,
IsConstraint(
_A("E<T1,T2,T3>"), _A("greater_than_with_requires<T,P>"), "T1,T3"));
REQUIRE_THAT(puml,
IsConstraint(
_A("F<T1,T2,T3>"), _A("greater_than_simple<T,L>"), "T1,T3"));
save_puml(config.output_directory() + "/" + diagram->name + ".puml", puml);
}

View File

@@ -281,6 +281,13 @@ ContainsMatcher IsClassTemplate(std::string const &str,
fmt::format("class \"{}<{}>\"", str, tmplt), caseSensitivity));
}
ContainsMatcher IsConcept(std::string const &str,
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
{
return ContainsMatcher(
CasedString("class " + str + " <<concept>>", caseSensitivity));
}
ContainsMatcher IsEnum(std::string const &str,
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
{
@@ -426,6 +433,18 @@ ContainsMatcher IsDependency(std::string const &from, std::string const &to,
CasedString(fmt::format("{} ..> {}", from, to), caseSensitivity));
}
ContainsMatcher IsConstraint(std::string const &from, std::string const &to,
std::string const &label = {},
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
{
if (label.empty())
return ContainsMatcher(
CasedString(fmt::format("{} ..> {}", from, to), caseSensitivity));
else
return ContainsMatcher(CasedString(
fmt::format("{} ..> {} : {}", from, to, label), caseSensitivity));
}
ContainsMatcher IsLayoutHint(std::string const &from, std::string const &hint,
std::string const &to,
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)