Added package diagram test case with C++20 module partitions
This commit is contained in:
13
tests/t30014/.clang-uml
Normal file
13
tests/t30014/.clang-uml
Normal file
@@ -0,0 +1,13 @@
|
||||
diagrams:
|
||||
t30014_package:
|
||||
type: package
|
||||
glob:
|
||||
- t30014.cc
|
||||
package_type: module
|
||||
include:
|
||||
modules:
|
||||
- t30014
|
||||
exclude:
|
||||
modules:
|
||||
- t30014.app:lib1.mod2
|
||||
using_module: t30014
|
||||
13
tests/t30014/src/lib1.cppm
Normal file
13
tests/t30014/src/lib1.cppm
Normal file
@@ -0,0 +1,13 @@
|
||||
export module t30014.app:lib1;
|
||||
|
||||
export namespace clanguml::t30014 {
|
||||
class B { };
|
||||
|
||||
template <typename T> class BB {
|
||||
T t;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
enum class BBB { bbb1, bbb2 };
|
||||
} // namespace detail
|
||||
} // namespace clanguml::t30014
|
||||
5
tests/t30014/src/lib1mod1.cppm
Normal file
5
tests/t30014/src/lib1mod1.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30014.app:lib1.mod1;
|
||||
|
||||
export namespace clanguml::t30014 {
|
||||
class D { };
|
||||
} // namespace clanguml::t30014
|
||||
5
tests/t30014/src/lib1mod2.cppm
Normal file
5
tests/t30014/src/lib1mod2.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30014.app:lib1.mod2;
|
||||
|
||||
export namespace clanguml::t30014 {
|
||||
class E { };
|
||||
} // namespace clanguml::t30014
|
||||
13
tests/t30014/src/lib2.cppm
Normal file
13
tests/t30014/src/lib2.cppm
Normal file
@@ -0,0 +1,13 @@
|
||||
export module t30014.app:lib2;
|
||||
|
||||
export namespace clanguml::t30014 {
|
||||
class C { };
|
||||
|
||||
template <typename T> class CC {
|
||||
T t;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
enum class CCC { ccc1, ccc2 };
|
||||
} // namespace detail
|
||||
} // namespace clanguml::t30014
|
||||
13
tests/t30014/src/t30014_mod.cppm
Normal file
13
tests/t30014/src/t30014_mod.cppm
Normal file
@@ -0,0 +1,13 @@
|
||||
export module t30014.app;
|
||||
import :lib1;
|
||||
import :lib1.mod1;
|
||||
import :lib1.mod2;
|
||||
import :lib2;
|
||||
|
||||
export namespace clanguml::t30014 {
|
||||
class A {
|
||||
int get() { return a; }
|
||||
|
||||
int a;
|
||||
};
|
||||
} // namespace clanguml::t30014
|
||||
6
tests/t30014/t30014.cc
Normal file
6
tests/t30014/t30014.cc
Normal file
@@ -0,0 +1,6 @@
|
||||
import t30014.app;
|
||||
|
||||
namespace clanguml {
|
||||
namespace t30014 {
|
||||
}
|
||||
}
|
||||
69
tests/t30014/test_case.h
Normal file
69
tests/t30014/test_case.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* tests/t30014/test_case.h
|
||||
*
|
||||
* Copyright (c) 2021-2023 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("t30014", "[test-case][package]")
|
||||
{
|
||||
auto [config, db] = load_config("t30014");
|
||||
|
||||
auto diagram = config.diagrams["t30014_package"];
|
||||
|
||||
REQUIRE(diagram->name == "t30014_package");
|
||||
|
||||
auto model = generate_package_diagram(*db, diagram);
|
||||
|
||||
REQUIRE(model->name() == "t30014_package");
|
||||
|
||||
{
|
||||
auto src = generate_package_puml(diagram, *model);
|
||||
AliasMatcher _A(src);
|
||||
|
||||
REQUIRE_THAT(src, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(src, EndsWith("@enduml\n"));
|
||||
|
||||
// Check if all packages exist
|
||||
REQUIRE_THAT(src, IsPackage("app"));
|
||||
REQUIRE_THAT(src, IsPackage(":lib1"));
|
||||
REQUIRE_THAT(src, IsPackage(":lib2"));
|
||||
REQUIRE_THAT(src, IsPackage("mod1"));
|
||||
REQUIRE_THAT(src, !IsPackage("mod2"));
|
||||
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", src);
|
||||
}
|
||||
|
||||
{
|
||||
auto j = generate_package_json(diagram, *model);
|
||||
|
||||
using namespace json;
|
||||
|
||||
save_json(config.output_directory(), diagram->name + ".json", j);
|
||||
}
|
||||
|
||||
{
|
||||
auto src = generate_package_mermaid(diagram, *model);
|
||||
|
||||
mermaid::AliasMatcher _A(src);
|
||||
using mermaid::IsPackage;
|
||||
|
||||
REQUIRE_THAT(src, IsPackage(_A("app")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":lib1")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":lib2")));
|
||||
REQUIRE_THAT(src, IsPackage(_A("mod1")));
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
|
||||
}
|
||||
}
|
||||
@@ -475,6 +475,7 @@ using namespace clanguml::test::matchers;
|
||||
#if defined(ENABLE_CXX_MODULES_TEST_CASES)
|
||||
#include "t30012/test_case.h"
|
||||
#include "t30013/test_case.h"
|
||||
#include "t30014/test_case.h"
|
||||
#endif
|
||||
///
|
||||
/// Include diagram tests
|
||||
|
||||
@@ -365,6 +365,9 @@ test_cases:
|
||||
- name: t30013
|
||||
title: C++20 modules package dependencies diagram test
|
||||
description:
|
||||
- name: t30014
|
||||
title: C++20 modules package diagram test with partitions
|
||||
description:
|
||||
Include diagrams:
|
||||
- name: t40001
|
||||
title: Basic include graph diagram test case
|
||||
|
||||
Reference in New Issue
Block a user