Added package diagram layout hints generation test case
This commit is contained in:
19
tests/t30007/.clang-uml
Normal file
19
tests/t30007/.clang-uml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
compilation_database_dir: ..
|
||||||
|
output_directory: puml
|
||||||
|
diagrams:
|
||||||
|
t30007_package:
|
||||||
|
type: package
|
||||||
|
glob:
|
||||||
|
- ../../tests/t30007/t30007.cc
|
||||||
|
include:
|
||||||
|
namespaces:
|
||||||
|
- clanguml::t30007
|
||||||
|
using_namespace:
|
||||||
|
- clanguml::t30007
|
||||||
|
layout:
|
||||||
|
C:
|
||||||
|
- up: 'A::AA'
|
||||||
|
- left: B
|
||||||
|
plantuml:
|
||||||
|
before:
|
||||||
|
- "' t30007 test package diagram"
|
||||||
33
tests/t30007/t30007.cc
Normal file
33
tests/t30007/t30007.cc
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
namespace clanguml {
|
||||||
|
namespace t30007 {
|
||||||
|
|
||||||
|
namespace B {
|
||||||
|
struct BB {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \uml{note[top] Compare layout with t30006.}
|
||||||
|
namespace A {
|
||||||
|
namespace AA {
|
||||||
|
struct A1 {
|
||||||
|
B::BB *b;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace C {
|
||||||
|
struct CC {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \uml{note[bottom] Bottom A note.}
|
||||||
|
namespace A {
|
||||||
|
namespace AA {
|
||||||
|
struct A2 {
|
||||||
|
C::CC *c;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
53
tests/t30007/test_case.h
Normal file
53
tests/t30007/test_case.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* tests/t30007/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("t30007", "[test-case][package]")
|
||||||
|
{
|
||||||
|
auto [config, db] = load_config("t30007");
|
||||||
|
|
||||||
|
auto diagram = config.diagrams["t30007_package"];
|
||||||
|
|
||||||
|
REQUIRE(diagram->should_include("clanguml::t30007::A"));
|
||||||
|
REQUIRE(diagram->should_include("clanguml::t30007::C"));
|
||||||
|
REQUIRE(!diagram->should_include("std::vector"));
|
||||||
|
|
||||||
|
REQUIRE(diagram->name == "t30007_package");
|
||||||
|
|
||||||
|
auto model = generate_package_diagram(db, diagram);
|
||||||
|
|
||||||
|
REQUIRE(model.name() == "t30007_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("A"));
|
||||||
|
REQUIRE_THAT(puml, IsPackage("B"));
|
||||||
|
REQUIRE_THAT(puml, IsPackage("C"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("AA"), _A("B")));
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("AA"), _A("C")));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsLayoutHint(_A("C"), "up", _A("AA")));
|
||||||
|
REQUIRE_THAT(puml, IsLayoutHint(_A("C"), "left", _A("B")));
|
||||||
|
|
||||||
|
save_puml(
|
||||||
|
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||||
|
}
|
||||||
@@ -182,6 +182,7 @@ using namespace clanguml::test::matchers;
|
|||||||
#include "t30004/test_case.h"
|
#include "t30004/test_case.h"
|
||||||
#include "t30005/test_case.h"
|
#include "t30005/test_case.h"
|
||||||
#include "t30006/test_case.h"
|
#include "t30006/test_case.h"
|
||||||
|
#include "t30007/test_case.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Other tests (e.g. configuration file)
|
// Other tests (e.g. configuration file)
|
||||||
|
|||||||
@@ -351,6 +351,14 @@ ContainsMatcher IsDependency(std::string const &from, std::string const &to,
|
|||||||
CasedString(fmt::format("{} ..> {}", from, to), caseSensitivity));
|
CasedString(fmt::format("{} ..> {}", from, to), caseSensitivity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContainsMatcher IsLayoutHint(std::string const &from, std::string const &hint,
|
||||||
|
std::string const &to,
|
||||||
|
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||||
|
{
|
||||||
|
return ContainsMatcher(CasedString(
|
||||||
|
fmt::format("{} -[hidden]{}- {}", from, hint, to), caseSensitivity));
|
||||||
|
}
|
||||||
|
|
||||||
ContainsMatcher HasNote(std::string const &cls, std::string const &position,
|
ContainsMatcher HasNote(std::string const &cls, std::string const &position,
|
||||||
std::string const ¬e,
|
std::string const ¬e,
|
||||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||||
|
|||||||
Reference in New Issue
Block a user