Added namespace package in class diagrams test case
This commit is contained in:
13
tests/t00036/.clang-uml
Normal file
13
tests/t00036/.clang-uml
Normal file
@@ -0,0 +1,13 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t00036_class:
|
||||
type: class
|
||||
generate_packages: true
|
||||
glob:
|
||||
- ../../tests/t00036/t00036.cc
|
||||
using_namespace:
|
||||
- clanguml::t00036
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00036
|
||||
36
tests/t00036/t00036.cc
Normal file
36
tests/t00036/t00036.cc
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace clanguml {
|
||||
namespace t00036 {
|
||||
|
||||
namespace ns1 {
|
||||
|
||||
enum class E {
|
||||
blue,
|
||||
yellow
|
||||
};
|
||||
|
||||
namespace ns11 {
|
||||
|
||||
template <typename T> struct A {
|
||||
T a;
|
||||
};
|
||||
|
||||
namespace ns111 {
|
||||
|
||||
struct B {
|
||||
A<int> a_int;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace ns2 {
|
||||
namespace ns22 {
|
||||
|
||||
struct C;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace t00036
|
||||
} // namespace clanguml
|
||||
51
tests/t00036/test_case.h
Normal file
51
tests/t00036/test_case.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* tests/t00036/test_case.cc
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* 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("t00036", "[test-case][class]")
|
||||
{
|
||||
auto [config, db] = load_config("t00036");
|
||||
|
||||
auto diagram = config.diagrams["t00036_class"];
|
||||
|
||||
REQUIRE(diagram->name == "t00036_class");
|
||||
REQUIRE(diagram->generate_packages() == true);
|
||||
|
||||
auto model = generate_class_diagram(db, diagram);
|
||||
|
||||
REQUIRE(model.name() == "t00036_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, IsClassTemplate("A", "T"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "int"));
|
||||
REQUIRE_THAT(puml, IsEnum(_A("E")));
|
||||
REQUIRE_THAT(puml, IsClass(_A("B")));
|
||||
REQUIRE_THAT(puml, IsClass(_A("C")));
|
||||
REQUIRE_THAT(puml, IsPackage("ns111"));
|
||||
REQUIRE_THAT(puml, IsPackage("ns22"));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, IsAggregation(_A("B"), _A("A<int>"), "+a_int"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
@@ -178,6 +178,7 @@ using namespace clanguml::test::matchers;
|
||||
#include "t00033/test_case.h"
|
||||
#include "t00034/test_case.h"
|
||||
#include "t00035/test_case.h"
|
||||
#include "t00036/test_case.h"
|
||||
|
||||
//
|
||||
// Sequence diagram tests
|
||||
|
||||
@@ -47,6 +47,7 @@ TEST_CASE("Test config inherited", "[unit-test]")
|
||||
CHECK(def.glob()[0] == "src/**/*.cc");
|
||||
CHECK(def.glob()[1] == "src/**/*.h");
|
||||
CHECK(clanguml::util::contains(def.using_namespace(), "clanguml"));
|
||||
CHECK(def.generate_packages() == false);
|
||||
|
||||
auto &cus = *cfg.diagrams["class_custom"];
|
||||
CHECK(cus.type() == clanguml::config::diagram_type::class_diagram);
|
||||
@@ -54,6 +55,7 @@ TEST_CASE("Test config inherited", "[unit-test]")
|
||||
CHECK(cus.glob()[0] == "src/main.cc");
|
||||
CHECK(clanguml::util::contains(cus.using_namespace(), "clanguml::ns1"));
|
||||
CHECK(cus.include_relations_also_as_members());
|
||||
CHECK(def.generate_packages() == false);
|
||||
}
|
||||
|
||||
TEST_CASE("Test config includes", "[unit-test]")
|
||||
|
||||
Reference in New Issue
Block a user