Added test case for inner type aliases with parent class template args

This commit is contained in:
Bartek Kryza
2022-06-07 22:49:13 +02:00
parent 5231fb43b4
commit 1de4a40ae9
11 changed files with 160 additions and 37 deletions

View File

@@ -48,11 +48,13 @@ using BVector2 = BVector;
using AIntString = AString<int>;
using ACharString = AString<char>;
using AWCharString = AString<wchar_t>;
using AStringString = AString<std::string>;
using BStringString = AStringString;
class R {
using AWCharString = AString<wchar_t>;
PairPairBA<bool> bapair;
APtr<bool> abool;

View File

@@ -61,7 +61,8 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml, IsField<Protected>("bs", "BVector"));
REQUIRE_THAT(puml, IsField<Public>("cb", "SimpleCallback<ACharString>"));
REQUIRE_THAT(puml, IsField<Public>("gcb", "GenericCallback<AWCharString>"));
REQUIRE_THAT(
puml, IsField<Public>("gcb", "GenericCallback<R::AWCharString>"));
REQUIRE_THAT(puml, IsField<Public>("vcb", "VoidCallback"));
REQUIRE_THAT(

13
tests/t00044/.clang-uml Normal file
View File

@@ -0,0 +1,13 @@
compilation_database_dir: ..
output_directory: puml
diagrams:
t00044_class:
type: class
generate_packages: true
glob:
- ../../tests/t00044/t00044.cc
using_namespace:
- clanguml::t00044
include:
namespaces:
- clanguml::t00044

35
tests/t00044/t00044.cc Normal file
View File

@@ -0,0 +1,35 @@
// Inspired by skypjack/entt signal handlers
// This test case checks that at least clang-uml does not crash on this code
namespace clanguml::t00044 {
template <typename T> class sink;
template <typename T, typename A> class signal_handler;
template <typename Ret, typename... Args, typename A>
class sink<signal_handler<Ret(Args...), A>> {
using signal_t = signal_handler<Ret(Args...), A>;
public:
sink(signal_t &sh)
: signal{&sh}
{
}
private:
signal_t *signal;
};
template <typename Ret, typename... Args, typename A>
class signal_handler<Ret(Args...), A> {
};
template <typename Ret, typename... Args, typename A>
sink(signal_handler<Ret(Args...), A> &)
-> sink<signal_handler<Ret(Args...), A>>;
signal_handler<void(int), bool> int_handler;
sink sink1{int_handler};
} // namespace clanguml::t00044

43
tests/t00044/test_case.h Normal file
View File

@@ -0,0 +1,43 @@
/**
* tests/t00044/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("t00044", "[test-case][class]")
{
auto [config, db] = load_config("t00044");
auto diagram = config.diagrams["t00044_class"];
REQUIRE(diagram->name == "t00044_class");
REQUIRE(diagram->generate_packages() == true);
auto model = generate_class_diagram(db, diagram);
REQUIRE(model->name() == "t00044_class");
auto puml = generate_class_puml(diagram, *model);
AliasMatcher _A(puml);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check dependants filter<void(int), bool>
REQUIRE_THAT(puml, IsClassTemplate("signal_handler", "Ret,Args...,A"));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
}

View File

@@ -225,6 +225,7 @@ using namespace clanguml::test::matchers;
#include "t00041/test_case.h"
#include "t00042/test_case.h"
#include "t00043/test_case.h"
#include "t00044/test_case.h"
//
// Sequence diagram tests