diff --git a/src/package_diagram/generators/plantuml/package_diagram_generator.cc b/src/package_diagram/generators/plantuml/package_diagram_generator.cc index c5adbcb9..2dc04c9d 100644 --- a/src/package_diagram/generators/plantuml/package_diagram_generator.cc +++ b/src/package_diagram/generators/plantuml/package_diagram_generator.cc @@ -90,9 +90,9 @@ void generator::generate_relationships( for (const auto &r : p.relationships()) { std::stringstream relstr; try { - relstr << m_model.to_alias(ns_relative(uns, r.destination())) - << " <.. " - << m_model.to_alias(ns_relative(uns, p.full_name(false))) + relstr << m_model.to_alias(ns_relative(uns, p.full_name(false))) + << " ..> " + << m_model.to_alias(ns_relative(uns, r.destination())) << '\n'; ostr << relstr.str(); } diff --git a/tests/t30002/test_case.h b/tests/t30002/test_case.h index 734e7701..9161a9ac 100644 --- a/tests/t30002/test_case.h +++ b/tests/t30002/test_case.h @@ -49,9 +49,30 @@ TEST_CASE("t30002", "[test-case][package]") REQUIRE_THAT(puml, Contains("component [A1]")); REQUIRE_THAT(puml, Contains("component [A2]")); REQUIRE_THAT(puml, Contains("component [A3]")); + REQUIRE_THAT(puml, Contains("component [A4]")); + REQUIRE_THAT(puml, Contains("component [A5]")); + REQUIRE_THAT(puml, Contains("component [A6]")); + REQUIRE_THAT(puml, Contains("component [A7]")); + REQUIRE_THAT(puml, Contains("component [A8]")); + REQUIRE_THAT(puml, Contains("component [A9]")); + REQUIRE_THAT(puml, Contains("component [A10]")); + REQUIRE_THAT(puml, Contains("component [A11]")); REQUIRE_THAT(puml, Contains("component [A12]")); + REQUIRE_THAT(puml, Contains("component [A13]")); - // REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("AAA"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A1"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A2"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A3"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A4"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A5"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A6"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A7"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A8"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A9"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A10"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A11"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A12"))); + REQUIRE_THAT(puml, IsDependency(_A("BBB"), _A("A13"))); save_puml( "./" + config.output_directory + "/" + diagram->name + ".puml", puml); diff --git a/tests/test_cases.h b/tests/test_cases.h index df8241d6..afe8d85b 100644 --- a/tests/test_cases.h +++ b/tests/test_cases.h @@ -168,19 +168,31 @@ struct AliasMatcher { std::string operator()(const std::string &name) { - std::vector patterns; - patterns.push_back("class \"" + name + "\" as "); - patterns.push_back("abstract \"" + name + "\" as "); - patterns.push_back("enum \"" + name + "\" as "); - patterns.push_back("component \"" + name + "\" as "); - patterns.push_back("component [" + name + "] as "); + std::vector patterns; + + const std::string alias_regex("([A-Z]_[0-9]+)"); + + patterns.push_back( + std::regex{"class\\s\"" + name + "\"\\sas\\s" + alias_regex}); + patterns.push_back( + std::regex{"abstract\\s\"" + name + "\"\\sas\\s" + alias_regex}); + patterns.push_back( + std::regex{"enum\\s\"" + name + "\"\\sas\\s" + alias_regex}); + patterns.push_back( + std::regex{"component\\s\"" + name + "\"\\sas\\s" + alias_regex}); + patterns.push_back( + std::regex{"component\\s\\[" + name + "\\]\\sas\\s" + alias_regex}); + + std::smatch base_match; for (const auto &line : puml) { for (const auto &pattern : patterns) { - const auto idx = line.find(pattern); - if (idx != std::string::npos) { - std::string res = line.substr(idx + pattern.size()); - return trim(res); + if (std::regex_search(line, base_match, pattern)) { + if (base_match.size() == 2) { + std::ssub_match base_sub_match = base_match[1]; + std::string alias = base_sub_match.str(); + return trim(alias); + } } } }