diff --git a/src/puml/class_diagram_generator.h b/src/puml/class_diagram_generator.h index 0701ef4c..7a2a1bf7 100644 --- a/src/puml/class_diagram_generator.h +++ b/src/puml/class_diagram_generator.h @@ -214,6 +214,9 @@ public: { ostr << "@startuml" << std::endl; + for (const auto &b : m_config.puml.before) + ostr << b << std::endl; + for (const auto &c : m_model.classes) { generate_aliases(c, ostr); ostr << std::endl; @@ -229,6 +232,9 @@ public: ostr << std::endl; } + for (const auto &b : m_config.puml.after) + ostr << b << std::endl; + ostr << "@enduml" << std::endl; } diff --git a/tests/t00000/.clanguml b/tests/t00000/.clanguml new file mode 100644 index 00000000..241b2cdd --- /dev/null +++ b/tests/t00000/.clanguml @@ -0,0 +1,20 @@ +compilation_database_dir: .. +output_directory: puml +diagrams: + t00000_class: + type: class + plantuml: + before: + - 'class "Foo" as C_001' + - 'class C_001 {' + - ' +int value' + - '}' + - 'C_001 <|-- ArrayList' + - 'note top of C_001: This is a very important class.' + - 'note "This is a\nfloating note" as N1' + - 'note "This note is connected\nto several objects." as N2' + - 'C_001 .. N2' + - 'N2 .. ArrayList' + - 'class "Boo" as C_002' + - 'class C_002 {' + - '}' diff --git a/tests/t00000/t00000.cc b/tests/t00000/t00000.cc new file mode 100644 index 00000000..e69de29b diff --git a/tests/t00000/test_case.h b/tests/t00000/test_case.h new file mode 100644 index 00000000..47e9c3ef --- /dev/null +++ b/tests/t00000/test_case.h @@ -0,0 +1,42 @@ +/** + * tests/t00000/test_case.cc + * + * Copyright (c) 2021 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("Test t00000", "[unit-test]") +{ + spdlog::set_level(spdlog::level::debug); + + auto [config, db] = load_config("t00000"); + + auto diagram = config.diagrams["t00000_class"]; + + auto model = generate_class_diagram(db, diagram); + + REQUIRE(model.name == "t00000_class"); + + auto puml = generate_class_puml(diagram, model); + AliasMatcher _A(puml); + + REQUIRE_THAT(puml, StartsWith("@startuml")); + REQUIRE_THAT(puml, EndsWith("@enduml\n")); + + REQUIRE_THAT(puml, IsClass(_A("Foo"))); + REQUIRE_THAT(puml, IsClass(_A("Boo"))); + + save_puml( + "./" + config.output_directory + "/" + diagram->name + ".puml", puml); +} diff --git a/tests/t00002/.clanguml b/tests/t00002/.clanguml index d1f97578..7c842001 100644 --- a/tests/t00002/.clanguml +++ b/tests/t00002/.clanguml @@ -10,8 +10,3 @@ diagrams: include: namespaces: - clanguml::t00002 - plantuml: - before: - - "' t00002 test class diagram" - after: - - 'note over "A": A class' diff --git a/tests/t00003/.clanguml b/tests/t00003/.clanguml index 6bd41e8d..b543b19e 100644 --- a/tests/t00003/.clanguml +++ b/tests/t00003/.clanguml @@ -10,8 +10,3 @@ diagrams: include: namespaces: - clanguml::t00003 - plantuml: - before: - - "' t00003 test class members" - after: - - 'note over "A": A class' diff --git a/tests/t00004/.clanguml b/tests/t00004/.clanguml index e7dba572..d9231e66 100644 --- a/tests/t00004/.clanguml +++ b/tests/t00004/.clanguml @@ -12,8 +12,3 @@ diagrams: include: namespaces: - clanguml::t00004 - plantuml: - before: - - "' t00004 test class members" - after: - - 'note over "A": A class' diff --git a/tests/test_cases.cc b/tests/test_cases.cc index 85a52fc7..0724d0f5 100644 --- a/tests/test_cases.cc +++ b/tests/test_cases.cc @@ -113,6 +113,7 @@ using clanguml::test::matchers::Protected; using clanguml::test::matchers::Public; using clanguml::test::matchers::Static; +#include "t00000/test_case.h" #include "t00001/test_case.h" #include "t00002/test_case.h" #include "t00003/test_case.h"