Added template insantiation relation

This commit is contained in:
Bartek Kryza
2021-03-10 00:03:03 +01:00
parent e07392dae6
commit 9cb21ab7a2
10 changed files with 267 additions and 16 deletions

12
tests/t00009/.clanguml Normal file
View File

@@ -0,0 +1,12 @@
compilation_database_dir: ..
output_directory: puml
diagrams:
t00009_class:
type: class
glob:
- ../../tests/t00009/t00009.cc
using_namespace:
- clanguml::t00009
include:
namespaces:
- clanguml::t00009

43
tests/t00009/t00009.cc Normal file
View File

@@ -0,0 +1,43 @@
#include <string>
#include <vector>
/*
@startuml
class "A<T>" as C_0000000046
class C_0000000046 {
+T value
}
class "A<int>" as ABC
class "A<std::string>" as ABCD
class "B" as C_0000000047
class C_0000000047 {
+A<int> aint
+A<std::string> astring
}
C_0000000046 <|.. ABC
C_0000000046 <|.. ABCD
ABC <-- C_0000000047 : aint
ABCD <-- C_0000000047 : astring
@enduml
*/
namespace clanguml {
namespace t00009 {
template <typename T> class A {
public:
T value;
};
class B {
public:
A<int> aint;
A<std::string> astring;
};
}
}

64
tests/t00009/test_case.h Normal file
View File

@@ -0,0 +1,64 @@
/**
* tests/t00009/test_case.cc
*
* Copyright (c) 2021 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("Test t00009", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00009");
auto diagram = config.diagrams["t00009_class"];
REQUIRE(diagram->name == "t00009_class");
REQUIRE(diagram->include.namespaces.size() == 1);
REQUIRE_THAT(diagram->include.namespaces,
VectorContains(std::string{"clanguml::t00009"}));
REQUIRE(diagram->exclude.namespaces.size() == 0);
REQUIRE(diagram->should_include("clanguml::t00009::A"));
REQUIRE(diagram->should_include("clanguml::t00009::B"));
auto model = generate_class_diagram(db, diagram);
REQUIRE(model.name == "t00009_class");
auto puml = generate_class_puml(diagram, model);
AliasMatcher _A(puml);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, IsClassTemplate("A", "T"));
REQUIRE_THAT(puml, IsClass(_A("B")));
/*
REQUIRE_THAT(puml, IsField(Public("T value")));
REQUIRE_THAT(puml, IsField(Public("T * pointer")));
REQUIRE_THAT(puml, IsField(Public("T & reference")));
REQUIRE_THAT(puml, IsField(Public("std::vector<P> values")));
REQUIRE_THAT(puml, IsField(Public("std::array<int, N> ints")));
REQUIRE_THAT(puml, IsField(Public("bool (*)(int, int) comparator")));
REQUIRE_THAT(puml, IsClassTemplate("B", "T, C<>"));
REQUIRE_THAT(puml, IsField(Public("C<T> template_template")));
*/
save_puml(
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
}

View File

@@ -119,3 +119,4 @@ using clanguml::test::matchers::Static;
#include "t00006/test_case.h"
#include "t00007/test_case.h"
#include "t00008/test_case.h"
#include "t00009/test_case.h"