From db3de87e8acb93efdd64f3b75a25c497dd9c8dfc Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 6 Mar 2022 00:24:11 +0100 Subject: [PATCH] Added anonymous struct test case --- tests/t00037/.clang-uml | 13 ++++++++++++ tests/t00037/t00037.cc | 26 ++++++++++++++++++++++++ tests/t00037/test_case.h | 44 ++++++++++++++++++++++++++++++++++++++++ tests/test_cases.cc | 1 + tests/test_cases.yaml | 3 +++ 5 files changed, 87 insertions(+) create mode 100644 tests/t00037/.clang-uml create mode 100644 tests/t00037/t00037.cc create mode 100644 tests/t00037/test_case.h diff --git a/tests/t00037/.clang-uml b/tests/t00037/.clang-uml new file mode 100644 index 00000000..9a8cd532 --- /dev/null +++ b/tests/t00037/.clang-uml @@ -0,0 +1,13 @@ +compilation_database_dir: .. +output_directory: puml +diagrams: + t00037_class: + type: class + generate_packages: true + glob: + - ../../tests/t00037/t00037.cc + using_namespace: + - clanguml::t00037 + include: + namespaces: + - clanguml::t00037 \ No newline at end of file diff --git a/tests/t00037/t00037.cc b/tests/t00037/t00037.cc new file mode 100644 index 00000000..c2b53adb --- /dev/null +++ b/tests/t00037/t00037.cc @@ -0,0 +1,26 @@ +namespace clanguml { +namespace t00037 { + +struct ST { + struct { + double t; + double x; + double y; + double z; + } dimensions; +}; + +struct A { + A() + { + st.dimensions.t = -1; + st.dimensions.x = 1; + st.dimensions.y = 1; + st.dimensions.z = 1; + } + + ST st; +}; + +} // namespace t00037 +} // namespace clanguml diff --git a/tests/t00037/test_case.h b/tests/t00037/test_case.h new file mode 100644 index 00000000..87927d99 --- /dev/null +++ b/tests/t00037/test_case.h @@ -0,0 +1,44 @@ +/** + * tests/t00037/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("t00037", "[test-case][class]") +{ + auto [config, db] = load_config("t00037"); + + auto diagram = config.diagrams["t00037_class"]; + + REQUIRE(diagram->name == "t00037_class"); + REQUIRE(diagram->generate_packages() == true); + + auto model = generate_class_diagram(db, diagram); + + REQUIRE(model.name() == "t00037_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("ST"))); + REQUIRE_THAT(puml, IsClass(_A("A"))); + REQUIRE_THAT(puml, IsInnerClass(_A("ST"), _A("<>"))); + + save_puml( + "./" + config.output_directory() + "/" + diagram->name + ".puml", puml); +} diff --git a/tests/test_cases.cc b/tests/test_cases.cc index 30e3727c..2257c8c1 100644 --- a/tests/test_cases.cc +++ b/tests/test_cases.cc @@ -179,6 +179,7 @@ using namespace clanguml::test::matchers; #include "t00034/test_case.h" #include "t00035/test_case.h" #include "t00036/test_case.h" +#include "t00037/test_case.h" // // Sequence diagram tests diff --git a/tests/test_cases.yaml b/tests/test_cases.yaml index 6a50c833..6c93e7e4 100644 --- a/tests/test_cases.yaml +++ b/tests/test_cases.yaml @@ -105,6 +105,9 @@ test_cases: - name: t00036 title: Class diagram with namespaces generated as packages description: + - name: t00037 + title: Anonymous nested struct test case + description: Sequence diagrams: - name: t20001 title: Basic sequence diagram test case