Added package diagram decorators test case

This commit is contained in:
Bartek Kryza
2022-01-26 20:11:03 +01:00
parent 62b2c73213
commit 3d074f1ddd
8 changed files with 114 additions and 6 deletions

View File

@@ -86,7 +86,6 @@ void generator::generate_relationships(
// Generate this packages relationship
if (m_config.should_include_relationship("dependency")) {
LOG_DBG("LOOKING FOR RELATIONSHIPS IN PACKAGE: {}", p.full_name(false));
for (const auto &r : p.relationships()) {
std::stringstream relstr;
try {

View File

@@ -122,6 +122,7 @@ public:
bool is_deprecated() const;
void set_deprecated(bool deprecated);
private:
bool is_deprecated_{false};
};

View File

@@ -106,6 +106,12 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
p->set_name(e.name());
p->set_namespace(package_parent);
if (ns_declaration.comment().has_value())
p->add_decorators(decorators::parse(
ns_declaration.comment().value()));
p->set_style(p->style_spec());
for (const auto &attr :
ns_declaration.attributes()) {
if (attr.kind() ==
@@ -115,10 +121,12 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
}
}
ctx.diagram().add_package(
package_parent, std::move(p));
ctx.set_current_package(
ctx.diagram().get_package(package_path));
if (!p->skip()) {
ctx.diagram().add_package(
package_parent, std::move(p));
ctx.set_current_package(
ctx.diagram().get_package(package_path));
}
}
ctx.push_namespace(e.name());

15
tests/t30004/.clang-uml Normal file
View File

@@ -0,0 +1,15 @@
compilation_database_dir: ..
output_directory: puml
diagrams:
t30004_package:
type: package
glob:
- ../../tests/t30004/t30004.cc
include:
namespaces:
- clanguml::t30004
using_namespace:
- clanguml::t30004
plantuml:
before:
- "' t30004 test package diagram"

31
tests/t30004/t30004.cc Normal file
View File

@@ -0,0 +1,31 @@
namespace clanguml {
namespace t30004 {
/// @uml{style[#green]}
namespace A {
/// @uml{note[ bottom ] Package AAA.}
namespace AAA {
}
/// \uml{note[right] Package BBB.}
namespace BBB {
}
///
/// @uml{note:t30004_package[bottom] CCCC package note.}
/// This is package CCC.
namespace CCC {
}
/// \uml{skip}
namespace DDD {
}
/// @uml{style[#pink;line:red;line.bold;text:red]}
/// \uml{note[top] We skipped DDD.}
namespace EEE {
}
}
}
}

53
tests/t30004/test_case.h Normal file
View File

@@ -0,0 +1,53 @@
/**
* tests/t30004/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("t30004", "[test-case][package]")
{
auto [config, db] = load_config("t30004");
auto diagram = config.diagrams["t30004_package"];
REQUIRE(diagram->include.namespaces.size() == 1);
REQUIRE_THAT(diagram->include.namespaces,
VectorContains(std::string{"clanguml::t30004"}));
REQUIRE(diagram->should_include("clanguml::t30004::A"));
REQUIRE(diagram->should_include("clanguml::t30004::C"));
REQUIRE(!diagram->should_include("std::vector"));
REQUIRE(diagram->name == "t30004_package");
auto model = generate_package_diagram(db, diagram);
REQUIRE(model.name() == "t30004_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("AAA"));
REQUIRE_THAT(puml, IsPackage("BBB"));
REQUIRE_THAT(puml, IsPackage("CCC"));
REQUIRE_THAT(puml, !IsPackage("DDD"));
REQUIRE_THAT(puml, IsPackage("EEE"));
save_puml(
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
}

View File

@@ -179,6 +179,7 @@ using namespace clanguml::test::matchers;
#include "t30001/test_case.h"
#include "t30002/test_case.h"
#include "t30003/test_case.h"
#include "t30004/test_case.h"
//
// Other tests (e.g. configuration file)

View File

@@ -426,7 +426,7 @@ ContainsMatcher IsDeprecated(std::string const &str,
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
{
return ContainsMatcher(
CasedString(str+" <<deprecated>> ", caseSensitivity));
CasedString(str + " <<deprecated>> ", caseSensitivity));
}
}
}