Added package diagram test case with C++20 module partitions dependencies
This commit is contained in:
@@ -7,7 +7,8 @@ file(GLOB_RECURSE TEST_CONFIG_YMLS test_config_data/*.yml
|
||||
test_compilation_database_data/*.json)
|
||||
|
||||
set(TEST_CASES_REQUIRING_CXX20 t00056 t00058 t00059 t00065 t00069)
|
||||
set(TEST_CASES_REQUIRING_CXX20_MODULES t00070 t00071 t30012 t30013)
|
||||
set(TEST_CASES_REQUIRING_CXX20_MODULES t00070 t00071
|
||||
t30012 t30013 t30014 t30015)
|
||||
|
||||
if(ENABLE_CXX_MODULES_TEST_CASES)
|
||||
foreach(CXX20_MOD_TC ${TEST_CASES_REQUIRING_CXX20_MODULES})
|
||||
|
||||
@@ -50,6 +50,12 @@ TEST_CASE("t30012", "[test-case][package]")
|
||||
|
||||
using namespace json;
|
||||
|
||||
REQUIRE(IsPackage(j, "app", "module"));
|
||||
REQUIRE(IsPackage(j, "app.lib1", "module"));
|
||||
REQUIRE(IsPackage(j, "app.lib2", "module"));
|
||||
REQUIRE(IsPackage(j, "app.lib1.mod1", "module"));
|
||||
REQUIRE(IsPackage(j, "app.lib1.mod2", "module"));
|
||||
|
||||
save_json(config.output_directory(), diagram->name + ".json", j);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import t30013.app;
|
||||
import t30013.mod1;
|
||||
import t30013.mod2;
|
||||
import t30013.mod3;
|
||||
import t30013.mod4;
|
||||
|
||||
@@ -83,25 +83,25 @@ TEST_CASE("t30013", "[test-case][package]")
|
||||
|
||||
using namespace json;
|
||||
|
||||
REQUIRE(IsPackage(j, "app"));
|
||||
REQUIRE(IsPackage(j, "mod1"));
|
||||
REQUIRE(IsPackage(j, "mod2"));
|
||||
REQUIRE(IsPackage(j, "mod3"));
|
||||
REQUIRE(IsPackage(j, "mod4"));
|
||||
REQUIRE(IsPackage(j, "mod5"));
|
||||
REQUIRE(IsPackage(j, "mod6"));
|
||||
REQUIRE(IsPackage(j, "mod7"));
|
||||
REQUIRE(IsPackage(j, "mod8"));
|
||||
REQUIRE(IsPackage(j, "mod9"));
|
||||
REQUIRE(IsPackage(j, "mod10"));
|
||||
REQUIRE(IsPackage(j, "mod11"));
|
||||
REQUIRE(IsPackage(j, "mod12"));
|
||||
REQUIRE(IsPackage(j, "mod13"));
|
||||
REQUIRE(IsPackage(j, "mod14"));
|
||||
REQUIRE(IsPackage(j, "mod15"));
|
||||
REQUIRE(IsPackage(j, "mod16"));
|
||||
REQUIRE(IsPackage(j, "mod17"));
|
||||
REQUIRE(IsPackage(j, "mod18"));
|
||||
REQUIRE(IsPackage(j, "app", "module"));
|
||||
REQUIRE(IsPackage(j, "mod1", "module"));
|
||||
REQUIRE(IsPackage(j, "mod2", "module"));
|
||||
REQUIRE(IsPackage(j, "mod3", "module"));
|
||||
REQUIRE(IsPackage(j, "mod4", "module"));
|
||||
REQUIRE(IsPackage(j, "mod5", "module"));
|
||||
REQUIRE(IsPackage(j, "mod6", "module"));
|
||||
REQUIRE(IsPackage(j, "mod7", "module"));
|
||||
REQUIRE(IsPackage(j, "mod8", "module"));
|
||||
REQUIRE(IsPackage(j, "mod9", "module"));
|
||||
REQUIRE(IsPackage(j, "mod10", "module"));
|
||||
REQUIRE(IsPackage(j, "mod11", "module"));
|
||||
REQUIRE(IsPackage(j, "mod12", "module"));
|
||||
REQUIRE(IsPackage(j, "mod13", "module"));
|
||||
REQUIRE(IsPackage(j, "mod14", "module"));
|
||||
REQUIRE(IsPackage(j, "mod15", "module"));
|
||||
REQUIRE(IsPackage(j, "mod16", "module"));
|
||||
REQUIRE(IsPackage(j, "mod17", "module"));
|
||||
REQUIRE(IsPackage(j, "mod18", "module"));
|
||||
|
||||
save_json(config.output_directory(), diagram->name + ".json", j);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,12 @@ TEST_CASE("t30014", "[test-case][package]")
|
||||
|
||||
using namespace json;
|
||||
|
||||
REQUIRE(IsPackage(j, "app", "module"));
|
||||
REQUIRE(IsPackage(j, "app:lib1", "module"));
|
||||
REQUIRE(IsPackage(j, "app:lib2", "module"));
|
||||
REQUIRE(IsPackage(j, "app:lib1.mod1", "module"));
|
||||
REQUIRE(!IsPackage(j, "app:lib1.mod2", "module"));
|
||||
|
||||
save_json(config.output_directory(), diagram->name + ".json", j);
|
||||
}
|
||||
|
||||
|
||||
10
tests/t30015/.clang-uml
Normal file
10
tests/t30015/.clang-uml
Normal file
@@ -0,0 +1,10 @@
|
||||
diagrams:
|
||||
t30015_package:
|
||||
type: package
|
||||
glob:
|
||||
- t30015.cc
|
||||
package_type: module
|
||||
include:
|
||||
modules:
|
||||
- t30015
|
||||
using_module: t30015
|
||||
72
tests/t30015/src/app.cppm
Normal file
72
tests/t30015/src/app.cppm
Normal file
@@ -0,0 +1,72 @@
|
||||
module;
|
||||
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
export module t30015.app;
|
||||
import t30015.lib1;
|
||||
|
||||
// import t30015.app;
|
||||
// import t30015.mod2;
|
||||
// import t30015.mod3;
|
||||
// import t30015.mod4;
|
||||
// import t30015.mod5;
|
||||
// import t30015.mod6;
|
||||
// import t30015.mod7;
|
||||
// import t30015.mod8;
|
||||
// import t30015.mod9;
|
||||
// import t30015.mod10;
|
||||
// import t30015.mod11;
|
||||
// import t30015.mod12;
|
||||
// import t30015.mod13;
|
||||
// import t30015.mod14;
|
||||
// import t30015.mod15;
|
||||
// import t30015.mod16;
|
||||
// import t30015.mod17;
|
||||
// import t30015.mod18;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
|
||||
class CBA : public CF {
|
||||
public:
|
||||
CA *ca_;
|
||||
CB<int> cb_;
|
||||
std::shared_ptr<CC> cc_;
|
||||
std::map<std::string, std::unique_ptr<CD>> *cd_;
|
||||
std::array<CO, 5> co_;
|
||||
static CP *cp_;
|
||||
|
||||
CBA() = default;
|
||||
|
||||
CBA(CN *cn) { }
|
||||
|
||||
friend CR;
|
||||
|
||||
template <typename... Item> CBA(std::tuple<Item...> &items) { }
|
||||
|
||||
void ce(const std::vector<CE> /*ce_*/) { }
|
||||
|
||||
std::shared_ptr<CG> cg() { return {}; }
|
||||
|
||||
template <typename T> void ch(std::map<T, std::shared_ptr<CH>> &ch_) { }
|
||||
|
||||
template <typename T> std::map<T, std::shared_ptr<CI>> ci(T * /*t*/)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
S s;
|
||||
};
|
||||
|
||||
void cj(std::unique_ptr<CJ> /*cj_*/) { }
|
||||
|
||||
std::unique_ptr<CK> ck() { return {}; }
|
||||
|
||||
template <typename T> void cl(std::map<T, std::shared_ptr<CL>> & /*ch_*/) { }
|
||||
|
||||
template <typename T> std::map<T, std::shared_ptr<CM>> cm() { return {}; }
|
||||
|
||||
} // namespace clanguml::t30013
|
||||
24
tests/t30015/src/lib1.cppm
Normal file
24
tests/t30015/src/lib1.cppm
Normal file
@@ -0,0 +1,24 @@
|
||||
export module t30015.lib1;
|
||||
|
||||
export import :mod1;
|
||||
export import :mod2;
|
||||
export import :mod3;
|
||||
export import :mod4;
|
||||
export import :mod5;
|
||||
export import :mod6;
|
||||
export import :mod7;
|
||||
export import :mod8;
|
||||
export import :mod9;
|
||||
export import :mod10;
|
||||
export import :mod11;
|
||||
export import :mod12;
|
||||
export import :mod13;
|
||||
export import :mod14;
|
||||
export import :mod15;
|
||||
export import :mod16;
|
||||
export import :mod17;
|
||||
export import :mod18;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
|
||||
}
|
||||
5
tests/t30015/src/mod1.cppm
Normal file
5
tests/t30015/src/mod1.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod1;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CA { };
|
||||
}
|
||||
5
tests/t30015/src/mod10.cppm
Normal file
5
tests/t30015/src/mod10.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod10;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CJ { };
|
||||
}
|
||||
5
tests/t30015/src/mod11.cppm
Normal file
5
tests/t30015/src/mod11.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod11;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CK { };
|
||||
}
|
||||
5
tests/t30015/src/mod12.cppm
Normal file
5
tests/t30015/src/mod12.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod12;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CL { };
|
||||
}
|
||||
5
tests/t30015/src/mod13.cppm
Normal file
5
tests/t30015/src/mod13.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod13;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CM { };
|
||||
}
|
||||
5
tests/t30015/src/mod14.cppm
Normal file
5
tests/t30015/src/mod14.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod14;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CN { };
|
||||
}
|
||||
5
tests/t30015/src/mod15.cppm
Normal file
5
tests/t30015/src/mod15.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod15;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CO { };
|
||||
}
|
||||
5
tests/t30015/src/mod16.cppm
Normal file
5
tests/t30015/src/mod16.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod16;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CP { };
|
||||
}
|
||||
5
tests/t30015/src/mod17.cppm
Normal file
5
tests/t30015/src/mod17.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod17;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CR { };
|
||||
}
|
||||
5
tests/t30015/src/mod18.cppm
Normal file
5
tests/t30015/src/mod18.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod18;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
enum class S { s1, s2, s3 };
|
||||
}
|
||||
7
tests/t30015/src/mod2.cppm
Normal file
7
tests/t30015/src/mod2.cppm
Normal file
@@ -0,0 +1,7 @@
|
||||
export module t30015.lib1:mod2;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
template <typename T> struct CB {
|
||||
T cb;
|
||||
};
|
||||
}
|
||||
5
tests/t30015/src/mod3.cppm
Normal file
5
tests/t30015/src/mod3.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod3;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CC { };
|
||||
}
|
||||
5
tests/t30015/src/mod4.cppm
Normal file
5
tests/t30015/src/mod4.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod4;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CD { };
|
||||
}
|
||||
5
tests/t30015/src/mod5.cppm
Normal file
5
tests/t30015/src/mod5.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod5;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CE { };
|
||||
}
|
||||
5
tests/t30015/src/mod6.cppm
Normal file
5
tests/t30015/src/mod6.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod6;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CF { };
|
||||
}
|
||||
5
tests/t30015/src/mod7.cppm
Normal file
5
tests/t30015/src/mod7.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod7;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CG { };
|
||||
}
|
||||
5
tests/t30015/src/mod8.cppm
Normal file
5
tests/t30015/src/mod8.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod8;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CH { };
|
||||
}
|
||||
5
tests/t30015/src/mod9.cppm
Normal file
5
tests/t30015/src/mod9.cppm
Normal file
@@ -0,0 +1,5 @@
|
||||
export module t30015.lib1:mod9;
|
||||
|
||||
export namespace clanguml::t30015 {
|
||||
struct CI { };
|
||||
}
|
||||
6
tests/t30015/t30015.cc
Normal file
6
tests/t30015/t30015.cc
Normal file
@@ -0,0 +1,6 @@
|
||||
import t30015.app;
|
||||
|
||||
namespace clanguml {
|
||||
namespace t30015 {
|
||||
}
|
||||
}
|
||||
160
tests/t30015/test_case.h
Normal file
160
tests/t30015/test_case.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* tests/t30015/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("t30015", "[test-case][package]")
|
||||
{
|
||||
auto [config, db] = load_config("t30015");
|
||||
|
||||
auto diagram = config.diagrams["t30015_package"];
|
||||
|
||||
REQUIRE(diagram->name == "t30015_package");
|
||||
|
||||
auto model = generate_package_diagram(*db, diagram);
|
||||
|
||||
REQUIRE(model->name() == "t30015_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(":mod1"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod2"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod3"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod4"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod5"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod6"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod7"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod8"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod9"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod10"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod11"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod12"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod13"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod14"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod15"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod16"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod17"));
|
||||
REQUIRE_THAT(src, IsPackage(":mod18"));
|
||||
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod1")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod2")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod3")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod4")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod5")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod6")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod7")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod8")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod9")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod10")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod11")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod12")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod13")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod14")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod15")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod16")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod17")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("app"), _A(":mod18")));
|
||||
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", src);
|
||||
}
|
||||
|
||||
{
|
||||
auto j = generate_package_json(diagram, *model);
|
||||
|
||||
using namespace json;
|
||||
|
||||
REQUIRE(IsPackage(j, "app", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod1", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod2", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod3", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod4", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod5", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod6", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod7", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod8", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod9", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod10", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod11", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod12", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod13", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod14", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod15", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod16", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod17", "module"));
|
||||
REQUIRE(IsPackage(j, "lib1:mod18", "module"));
|
||||
|
||||
save_json(config.output_directory(), diagram->name + ".json", j);
|
||||
}
|
||||
|
||||
{
|
||||
auto src = generate_package_mermaid(diagram, *model);
|
||||
|
||||
mermaid::AliasMatcher _A(src);
|
||||
using mermaid::IsPackage;
|
||||
using mermaid::IsPackageDependency;
|
||||
|
||||
REQUIRE_THAT(src, IsPackage(_A("app")));
|
||||
REQUIRE_THAT(src, IsPackage(_A("lib1")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod1")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod2")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod3")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod4")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod5")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod6")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod7")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod8")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod9")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod10")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod11")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod12")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod13")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod14")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod15")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod16")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod17")));
|
||||
REQUIRE_THAT(src, IsPackage(_A(":mod18")));
|
||||
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod1")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod2")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod3")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod4")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod5")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod6")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod7")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod8")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod9")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod10")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod11")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod12")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod13")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod14")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod15")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod16")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod17")));
|
||||
REQUIRE_THAT(src, IsPackageDependency(_A("app"), _A(":mod18")));
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
|
||||
}
|
||||
}
|
||||
@@ -476,6 +476,7 @@ using namespace clanguml::test::matchers;
|
||||
#include "t30012/test_case.h"
|
||||
#include "t30013/test_case.h"
|
||||
#include "t30014/test_case.h"
|
||||
#include "t30015/test_case.h"
|
||||
#endif
|
||||
///
|
||||
/// Include diagram tests
|
||||
@@ -520,4 +521,4 @@ int main(int argc, char *argv[])
|
||||
clih.handle_options(argvv.size(), argvv.data());
|
||||
|
||||
return session.run();
|
||||
}
|
||||
}
|
||||
@@ -1210,7 +1210,8 @@ std::optional<nlohmann::json> get_element(
|
||||
if (e["display_name"] == name)
|
||||
return {e};
|
||||
|
||||
if (e["type"] == "namespace" || e["type"] == "folder") {
|
||||
if (e["type"] == "namespace" || e["type"] == "folder" ||
|
||||
e["type"] == "module") {
|
||||
auto maybe_e = get_element(e, name);
|
||||
if (maybe_e)
|
||||
return maybe_e;
|
||||
@@ -1258,13 +1259,35 @@ auto get_relationship(const nlohmann::json &j, const std::string &from,
|
||||
|
||||
std::string expand_name(const nlohmann::json &j, const std::string &name)
|
||||
{
|
||||
if (!j.contains("using_namespace"))
|
||||
return name;
|
||||
using clanguml::class_diagram::model::path_type;
|
||||
using clanguml::common::model::path;
|
||||
using config::package_type_t;
|
||||
|
||||
if (name.find("::") == 0)
|
||||
return name;
|
||||
if (!j.contains("package_type") ||
|
||||
j["package_type"] == to_string(package_type_t::kNamespace)) {
|
||||
if (!j.contains("using_namespace"))
|
||||
return name;
|
||||
|
||||
return fmt::format("{}::{}", j["using_namespace"].get<std::string>(), name);
|
||||
auto full_path = path{j["using_namespace"].get<std::string>()};
|
||||
full_path |= path{name};
|
||||
|
||||
return full_path.to_string();
|
||||
}
|
||||
|
||||
if (j["package_type"] == to_string(package_type_t::kModule)) {
|
||||
if (!j.contains("using_module"))
|
||||
return name;
|
||||
|
||||
auto full_path =
|
||||
path{j["using_module"].get<std::string>(), path_type::kModule};
|
||||
full_path |= path{name, path_type::kModule};
|
||||
|
||||
auto res = full_path.to_string();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
bool HasTitle(const nlohmann::json &j, const std::string &title)
|
||||
@@ -1318,10 +1341,11 @@ bool IsEnum(const nlohmann::json &j, const std::string &name)
|
||||
return e && e->at("type") == "enum";
|
||||
}
|
||||
|
||||
bool IsPackage(const nlohmann::json &j, const std::string &name)
|
||||
bool IsPackage(const nlohmann::json &j, const std::string &name,
|
||||
const std::string &type = "namespace")
|
||||
{
|
||||
auto e = get_element(j, expand_name(j, name));
|
||||
return e && e->at("type") == "namespace";
|
||||
return e && e->at("type") == type;
|
||||
}
|
||||
|
||||
bool IsFolder(const nlohmann::json &j, const std::string &name)
|
||||
|
||||
@@ -368,6 +368,9 @@ test_cases:
|
||||
- name: t30014
|
||||
title: C++20 modules package diagram test with partitions
|
||||
description:
|
||||
- name: t30015
|
||||
title: C++20 modules package diagram test with partition dependencies
|
||||
description:
|
||||
Include diagrams:
|
||||
- name: t40001
|
||||
title: Basic include graph diagram test case
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "class_diagram/model/class.h"
|
||||
#include "common/model/namespace.h"
|
||||
#include "common/model/package.h"
|
||||
#include "common/model/template_parameter.h"
|
||||
|
||||
TEST_CASE("Test namespace_", "[unit-test]")
|
||||
@@ -407,3 +408,53 @@ TEST_CASE(
|
||||
CHECK(tp1.calculate_specialization_match(tp2) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test common::model::package full_name", "[unit-test]")
|
||||
{
|
||||
using clanguml::common::model::package;
|
||||
using clanguml::common::model::path;
|
||||
using clanguml::common::model::path_type;
|
||||
|
||||
{
|
||||
auto using_namespace = path{"A::B::C"};
|
||||
auto pkg = package(using_namespace);
|
||||
pkg.set_name("G");
|
||||
pkg.set_namespace(path{"A::B::C::D::E::F"});
|
||||
|
||||
CHECK(pkg.full_name(false) == "A::B::C::D::E::F::G");
|
||||
CHECK(pkg.full_name(true) == "D::E::F::G");
|
||||
|
||||
CHECK(pkg.doxygen_link().value() ==
|
||||
"namespaceA_1_1B_1_1C_1_1D_1_1E_1_1F_1_1G.html");
|
||||
}
|
||||
|
||||
{
|
||||
auto using_namespace = path{"/A/B/C", path_type::kFilesystem};
|
||||
auto pkg = package(using_namespace, path_type::kFilesystem);
|
||||
pkg.set_name("G");
|
||||
pkg.set_namespace(path{"/A/B/C/D/E/F", path_type::kFilesystem});
|
||||
|
||||
CHECK(pkg.full_name(false) == "A/B/C/D/E/F/G");
|
||||
CHECK(pkg.full_name(true) == "D/E/F/G");
|
||||
}
|
||||
|
||||
{
|
||||
auto using_namespace = path{"A.B.C", path_type::kModule};
|
||||
auto pkg = package(using_namespace, path_type::kModule);
|
||||
pkg.set_name("G");
|
||||
pkg.set_namespace(path{"A.B.C.D:E.F", path_type::kModule});
|
||||
|
||||
CHECK(pkg.full_name(false) == "A.B.C.D:E.F.G");
|
||||
CHECK(pkg.full_name(true) == "D:E.F.G");
|
||||
}
|
||||
|
||||
{
|
||||
auto using_namespace = path{"A.B.C", path_type::kModule};
|
||||
auto pkg = package(using_namespace, path_type::kModule);
|
||||
pkg.set_name(":D");
|
||||
pkg.set_namespace(path{"A.B.C", path_type::kModule});
|
||||
|
||||
CHECK(pkg.full_name(false) == "A.B.C:D");
|
||||
CHECK(pkg.full_name(true) == ":D");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user