diff --git a/tests/t30007/.clang-uml b/tests/t30007/.clang-uml new file mode 100644 index 00000000..96c875a0 --- /dev/null +++ b/tests/t30007/.clang-uml @@ -0,0 +1,19 @@ +compilation_database_dir: .. +output_directory: puml +diagrams: + t30007_package: + type: package + glob: + - ../../tests/t30007/t30007.cc + include: + namespaces: + - clanguml::t30007 + using_namespace: + - clanguml::t30007 + layout: + C: + - up: 'A::AA' + - left: B + plantuml: + before: + - "' t30007 test package diagram" \ No newline at end of file diff --git a/tests/t30007/t30007.cc b/tests/t30007/t30007.cc new file mode 100644 index 00000000..e79461ab --- /dev/null +++ b/tests/t30007/t30007.cc @@ -0,0 +1,33 @@ +namespace clanguml { +namespace t30007 { + +namespace B { +struct BB { +}; +} + +/// \uml{note[top] Compare layout with t30006.} +namespace A { +namespace AA { +struct A1 { + B::BB *b; +}; +} +} + +namespace C { +struct CC { +}; +} + +/// \uml{note[bottom] Bottom A note.} +namespace A { +namespace AA { +struct A2 { + C::CC *c; +}; +} +} + +} +} \ No newline at end of file diff --git a/tests/t30007/test_case.h b/tests/t30007/test_case.h new file mode 100644 index 00000000..130f1e96 --- /dev/null +++ b/tests/t30007/test_case.h @@ -0,0 +1,53 @@ +/** + * tests/t30007/test_case.cc + * + * Copyright (c) 2021-2022 Bartek Kryza + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +TEST_CASE("t30007", "[test-case][package]") +{ + auto [config, db] = load_config("t30007"); + + auto diagram = config.diagrams["t30007_package"]; + + REQUIRE(diagram->should_include("clanguml::t30007::A")); + REQUIRE(diagram->should_include("clanguml::t30007::C")); + REQUIRE(!diagram->should_include("std::vector")); + + REQUIRE(diagram->name == "t30007_package"); + + auto model = generate_package_diagram(db, diagram); + + REQUIRE(model.name() == "t30007_package"); + + auto puml = generate_package_puml(diagram, model); + AliasMatcher _A(puml); + + REQUIRE_THAT(puml, StartsWith("@startuml")); + REQUIRE_THAT(puml, EndsWith("@enduml\n")); + + REQUIRE_THAT(puml, IsPackage("A")); + REQUIRE_THAT(puml, IsPackage("B")); + REQUIRE_THAT(puml, IsPackage("C")); + + REQUIRE_THAT(puml, IsDependency(_A("AA"), _A("B"))); + REQUIRE_THAT(puml, IsDependency(_A("AA"), _A("C"))); + + REQUIRE_THAT(puml, IsLayoutHint(_A("C"), "up", _A("AA"))); + REQUIRE_THAT(puml, IsLayoutHint(_A("C"), "left", _A("B"))); + + save_puml( + "./" + config.output_directory() + "/" + diagram->name + ".puml", puml); +} diff --git a/tests/test_cases.cc b/tests/test_cases.cc index 922e36be..e721378d 100644 --- a/tests/test_cases.cc +++ b/tests/test_cases.cc @@ -182,6 +182,7 @@ using namespace clanguml::test::matchers; #include "t30004/test_case.h" #include "t30005/test_case.h" #include "t30006/test_case.h" +#include "t30007/test_case.h" // // Other tests (e.g. configuration file) diff --git a/tests/test_cases.h b/tests/test_cases.h index c18f3c5f..b20dbd8b 100644 --- a/tests/test_cases.h +++ b/tests/test_cases.h @@ -351,6 +351,14 @@ ContainsMatcher IsDependency(std::string const &from, std::string const &to, CasedString(fmt::format("{} ..> {}", from, to), caseSensitivity)); } +ContainsMatcher IsLayoutHint(std::string const &from, std::string const &hint, + std::string const &to, + CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes) +{ + return ContainsMatcher(CasedString( + fmt::format("{} -[hidden]{}- {}", from, hint, to), caseSensitivity)); +} + ContainsMatcher HasNote(std::string const &cls, std::string const &position, std::string const ¬e, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)