Added test case for package diagram from directory structure
This commit is contained in:
17
tests/t30010/.clang-uml
Normal file
17
tests/t30010/.clang-uml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
compilation_database_dir: ..
|
||||||
|
output_directory: puml
|
||||||
|
diagrams:
|
||||||
|
t30010_package:
|
||||||
|
type: package
|
||||||
|
generate_packages: true
|
||||||
|
package_type: directory
|
||||||
|
glob:
|
||||||
|
- t30010.cc
|
||||||
|
relative_to: ../../../tests/t30010
|
||||||
|
include:
|
||||||
|
namespaces:
|
||||||
|
- clanguml::t30010
|
||||||
|
# paths:
|
||||||
|
# - .
|
||||||
|
using_namespace:
|
||||||
|
- clanguml::t30010
|
||||||
20
tests/t30010/app/app.h
Normal file
20
tests/t30010/app/app.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../libraries/lib1/lib1.h"
|
||||||
|
#include "../libraries/lib2/lib2.h"
|
||||||
|
#include "../libraries/lib3/lib3.h"
|
||||||
|
#include "../libraries/lib4/lib4.h"
|
||||||
|
|
||||||
|
namespace clanguml {
|
||||||
|
namespace t30010 {
|
||||||
|
|
||||||
|
struct App {
|
||||||
|
library1::A *a;
|
||||||
|
library2::B<int> *b;
|
||||||
|
library3::E e;
|
||||||
|
|
||||||
|
void c(library4::C *) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
tests/t30010/libraries/lib1/lib1.h
Normal file
11
tests/t30010/libraries/lib1/lib1.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace clanguml {
|
||||||
|
namespace t30010 {
|
||||||
|
namespace library1 {
|
||||||
|
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
tests/t30010/libraries/lib2/lib2.h
Normal file
13
tests/t30010/libraries/lib2/lib2.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace clanguml {
|
||||||
|
namespace t30010 {
|
||||||
|
namespace library2 {
|
||||||
|
|
||||||
|
template <typename T> struct B {
|
||||||
|
T b;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
tests/t30010/libraries/lib3/lib3.h
Normal file
11
tests/t30010/libraries/lib3/lib3.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace clanguml {
|
||||||
|
namespace t30010 {
|
||||||
|
namespace library3 {
|
||||||
|
|
||||||
|
enum E { e1, e2, e3 };
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
tests/t30010/libraries/lib4/lib4.h
Normal file
11
tests/t30010/libraries/lib4/lib4.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace clanguml {
|
||||||
|
namespace t30010 {
|
||||||
|
namespace library4 {
|
||||||
|
|
||||||
|
struct C { };
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
tests/t30010/t30010.cc
Normal file
9
tests/t30010/t30010.cc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "app/app.h"
|
||||||
|
|
||||||
|
namespace clanguml {
|
||||||
|
namespace t30010 {
|
||||||
|
|
||||||
|
App app;
|
||||||
|
|
||||||
|
} // namespace t30002
|
||||||
|
} // namespace clanguml
|
||||||
63
tests/t30010/test_case.h
Normal file
63
tests/t30010/test_case.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* tests/t30010/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("t30010", "[test-case][package]")
|
||||||
|
{
|
||||||
|
auto [config, db] = load_config("t30010");
|
||||||
|
|
||||||
|
auto diagram = config.diagrams["t30010_package"];
|
||||||
|
|
||||||
|
REQUIRE(diagram->name == "t30010_package");
|
||||||
|
|
||||||
|
auto model = generate_package_diagram(*db, diagram);
|
||||||
|
|
||||||
|
REQUIRE(model->name() == "t30010_package");
|
||||||
|
|
||||||
|
{
|
||||||
|
auto puml = generate_package_puml(diagram, *model);
|
||||||
|
AliasMatcher _A(puml);
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||||
|
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsPackage("app"));
|
||||||
|
REQUIRE_THAT(puml, IsPackage("libraries"));
|
||||||
|
REQUIRE_THAT(puml, IsPackage("lib1"));
|
||||||
|
REQUIRE_THAT(puml, IsPackage("lib2"));
|
||||||
|
REQUIRE_THAT(puml, !IsPackage("library1"));
|
||||||
|
REQUIRE_THAT(puml, !IsPackage("library2"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("app"), _A("lib1")));
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("app"), _A("lib2")));
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("app"), _A("lib3")));
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("app"), _A("lib4")));
|
||||||
|
// REQUIRE_THAT(puml, IsDependency(_A("app"), _A("library1")));
|
||||||
|
// REQUIRE_THAT(puml, IsDependency(_A("app"), _A("library1")));
|
||||||
|
|
||||||
|
save_puml(
|
||||||
|
config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto j = generate_package_json(diagram, *model);
|
||||||
|
|
||||||
|
using namespace json;
|
||||||
|
|
||||||
|
save_json(config.output_directory() + "/" + diagram->name + ".json", j);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user