Adding template base class inheritance inference

This commit is contained in:
Bartek Kryza
2021-08-03 18:17:18 +02:00
parent fb5a69d5e5
commit 868ee1e04b
5 changed files with 152 additions and 0 deletions

12
tests/t00032/.clang-uml Normal file
View File

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

37
tests/t00032/t00032.cc Normal file
View File

@@ -0,0 +1,37 @@
#include <memory>
#include <vector>
namespace clanguml {
namespace t00032 {
struct Base {
};
struct TBase {
};
struct A {
void operator()() { }
};
struct B {
void operator()() { }
};
struct C {
void operator()() { }
};
template <typename T, typename... Ts>
struct Overload : public Base, public T, public Ts... {
using Ts::operator()...;
};
template <class... Ts> Overload(Ts...) -> Overload<Ts...>;
struct R {
Overload<TBase, A, B, C> overload;
};
} // namespace t00032
} // namespace clanguml

49
tests/t00032/test_case.h Normal file
View File

@@ -0,0 +1,49 @@
/**
* tests/t00032/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("t00032", "[test-case][class]")
{
auto [config, db] = load_config("t00032");
auto diagram = config.diagrams["t00032_class"];
REQUIRE(diagram->name == "t00032_class");
REQUIRE(diagram->include.namespaces.size() == 1);
REQUIRE_THAT(diagram->include.namespaces,
VectorContains(std::string{"clanguml::t00032"}));
REQUIRE(diagram->exclude.namespaces.size() == 0);
REQUIRE(diagram->should_include("clanguml::t00032::A"));
auto model = generate_class_diagram(db, diagram);
REQUIRE(model.name == "t00032_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, IsClass(_A("A")));
save_puml(
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
}

View File

@@ -135,6 +135,7 @@ using namespace clanguml::test::matchers;
#include "t00029/test_case.h"
#include "t00030/test_case.h"
#include "t00031/test_case.h"
#include "t00032/test_case.h"
//
// Sequence diagram tests