Added parents (base classes) diagram filter

This commit is contained in:
Bartek Kryza
2023-03-06 22:32:02 +01:00
parent 8ba0239283
commit 8f99e2fc2f
11 changed files with 158 additions and 0 deletions

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

@@ -0,0 +1,15 @@
compilation_database_dir: ..
output_directory: puml
diagrams:
t00060_class:
type: class
glob:
- ../../tests/t00060/t00060.cc
include:
namespaces:
- clanguml::t00060
parents:
- clanguml::t00060::D
- clanguml::t00060::H<T,P>
using_namespace:
- clanguml::t00060

20
tests/t00060/t00060.cc Normal file
View File

@@ -0,0 +1,20 @@
namespace clanguml {
namespace t00060 {
struct A { };
struct B : public A { };
struct C : public A { };
struct D : public B, public C { };
struct E : public C { };
struct F : public D { };
template <typename T> struct G {
T g;
};
template <typename T, typename P> struct H : public G<T> {
G<T> h;
P hh;
};
}
}

50
tests/t00060/test_case.h Normal file
View File

@@ -0,0 +1,50 @@
/**
* tests/t00060/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("t00060", "[test-case][class]")
{
auto [config, db] = load_config("t00060");
auto diagram = config.diagrams["t00060_class"];
REQUIRE(diagram->name == "t00060_class");
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00060_class");
auto puml = generate_class_puml(diagram, *model);
AliasMatcher _A(puml);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all classes exist
REQUIRE_THAT(puml, IsClass(_A("A")));
REQUIRE_THAT(puml, IsClass(_A("B")));
REQUIRE_THAT(puml, IsClass(_A("C")));
REQUIRE_THAT(puml, IsClass(_A("D")));
REQUIRE_THAT(puml, !IsClass(_A("E")));
REQUIRE_THAT(puml, !IsClass(_A("F")));
// Check if class templates exist
REQUIRE_THAT(puml, IsClassTemplate("G", "T"));
REQUIRE_THAT(puml, IsClassTemplate("H", "T,P"));
save_puml(config.output_directory() + "/" + diagram->name + ".puml", puml);
}

View File

@@ -263,6 +263,8 @@ using namespace clanguml::test::matchers;
#include "t00058/test_case.h"
#include "t00059/test_case.h"
#endif
#include "t00060/test_case.h"
///
/// Sequence diagram tests
///

View File

@@ -174,6 +174,9 @@ test_cases:
- name: t00059
title: Non-virtual abstract factory pattern using concepts test case
description:
- name: t00060
title: Parents (base classes) diagram filter test case
description:
Sequence diagrams:
- name: t20001
title: Basic sequence diagram test case