Improved rendering of template methods in class diagrams
This commit is contained in:
@@ -19,7 +19,6 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${LIBCLANG_CXXFLAGS} ${TEST_DISAB
|
||||
|
||||
if(APPLE)
|
||||
# Without this, clang-uml test cases fail with error saying that clang cannot find stdarg.h
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${LLVM_LIBRARY_DIR}/clang/${LLVM_PACKAGE_VERSION}/include")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -I${LLVM_LIBRARY_DIR}/clang/${LLVM_PACKAGE_VERSION}/include")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -I${LLVM_LIBRARY_DIR}/clang/${LLVM_PACKAGE_VERSION}/include")
|
||||
endif(APPLE)
|
||||
|
||||
@@ -40,8 +40,8 @@ TEST_CASE("t00051", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsInnerClass(_A("A"), _A("A::custom_thread2")));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
(IsMethod<Public>(
|
||||
"custom_thread1", "void", "Function && f, Args &&... args")));
|
||||
(IsMethod<Public>("custom_thread1<Function,Args...>", "void",
|
||||
"Function && f, Args &&... args")));
|
||||
REQUIRE_THAT(puml,
|
||||
(IsMethod<Public>("thread", "void",
|
||||
"(lambda at ../../tests/t00051/t00051.cc:59:27) && ")));
|
||||
|
||||
12
tests/t00052/.clang-uml
Normal file
12
tests/t00052/.clang-uml
Normal file
@@ -0,0 +1,12 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t00052_class:
|
||||
type: class
|
||||
glob:
|
||||
- ../../tests/t00052/t00052.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00052
|
||||
using_namespace:
|
||||
- clanguml::t00052
|
||||
19
tests/t00052/t00052.cc
Normal file
19
tests/t00052/t00052.cc
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace clanguml {
|
||||
namespace t00052 {
|
||||
|
||||
class A {
|
||||
public:
|
||||
template <typename T> T a(T p) { return p; }
|
||||
|
||||
template <typename F, typename Q> void aa(F &&f, Q q) { f(q); }
|
||||
};
|
||||
|
||||
template <typename T> class B {
|
||||
public:
|
||||
T b(T t) { return t; }
|
||||
|
||||
template <typename F> T bb(F &&f, T t) { return f(t); }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
50
tests/t00052/test_case.h
Normal file
50
tests/t00052/test_case.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* tests/t00052/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("t00052", "[test-case][class]")
|
||||
{
|
||||
auto [config, db] = load_config("t00052");
|
||||
|
||||
auto diagram = config.diagrams["t00052_class"];
|
||||
|
||||
REQUIRE(diagram->name == "t00052_class");
|
||||
|
||||
auto model = generate_class_diagram(*db, diagram);
|
||||
|
||||
REQUIRE(model->name() == "t00052_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")));
|
||||
|
||||
// Check if class templates exist
|
||||
REQUIRE_THAT(puml, IsClassTemplate("B", "T"));
|
||||
|
||||
// Check if all methods exist
|
||||
REQUIRE_THAT(puml, (IsMethod<Public>("a<T>", "T", "T p")));
|
||||
REQUIRE_THAT(puml, (IsMethod<Public>("aa<F,Q>", "void", "F && f, Q q")));
|
||||
REQUIRE_THAT(puml, (IsMethod<Public>("b", "T", "T t")));
|
||||
REQUIRE_THAT(puml, (IsMethod<Public>("bb<F>", "T", "F && f, T t")));
|
||||
|
||||
save_puml(config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
@@ -245,6 +245,7 @@ using namespace clanguml::test::matchers;
|
||||
#include "t00049/test_case.h"
|
||||
#include "t00050/test_case.h"
|
||||
#include "t00051/test_case.h"
|
||||
#include "t00052/test_case.h"
|
||||
|
||||
///
|
||||
/// Sequence diagram tests
|
||||
|
||||
@@ -150,6 +150,9 @@ test_cases:
|
||||
- name: t00051
|
||||
title: Test case for relative paths in lambda names
|
||||
description:
|
||||
- name: t00052
|
||||
title: Test case for template methods rendering
|
||||
description:
|
||||
Sequence diagrams:
|
||||
- name: t20001
|
||||
title: Basic sequence diagram test case
|
||||
|
||||
Reference in New Issue
Block a user