Merge pull request #228 from bkryza/add-coroutine-testcase

Add coroutine testcase
This commit is contained in:
Bartek Kryza
2024-01-11 17:10:25 +01:00
committed by GitHub
730 changed files with 20748 additions and 7689 deletions

View File

@@ -1,11 +1,31 @@
file(GLOB_RECURSE TEST_CASE_SOURCES t*/*.cc t*/*.c t*/src/*.c)
file(GLOB_RECURSE TEST_CASE_MODULE_SOURCES t*/src/*.cppm)
file(GLOB_RECURSE TEST_CASE_CONFIGS t*/.clang-uml)
file(GLOB_RECURSE TEST_CONFIG_YMLS test_config_data/*.yml
test_compilation_database_data/*.yml
test_compilation_database_data/*.json)
set(TEST_CASES_REQUIRING_CXX20 t00056 t00058 t00059 t00065)
set(TEST_CASES_REQUIRING_CXX20 t00056 t00058 t00059 t00065 t00069)
set(TEST_CASES_REQUIRING_CXX20_MODULES t00070 t00071 t00072
t30012 t30013 t30014 t30015)
if(ENABLE_CXX_MODULES_TEST_CASES)
foreach(CXX20_MOD_TC ${TEST_CASES_REQUIRING_CXX20_MODULES})
list(APPEND TEST_CASES_REQUIRING_CXX20 ${CXX20_MOD_TC})
endforeach()
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
else()
foreach(CXX20_MOD_TC ${TEST_CASES_REQUIRING_CXX20_MODULES})
list(FILTER TEST_CASE_SOURCES
EXCLUDE
REGEX ".*${CXX20_MOD_TC}.*")
list(FILTER TEST_CASE_CONFIGS
EXCLUDE
REGEX ".*${CXX20_MOD_TC}.*")
endforeach()
endif(ENABLE_CXX_MODULES_TEST_CASES)
set(CLANG_UML_TEST_LIBRARIES
clang-umllib
@@ -19,6 +39,9 @@ endif(MSVC)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_20 SUPPORTS_CXX_STD_20)
message(STATUS "Enabling C++20 test cases")
# Remove test cases which require C++20 if they are not supported here
if(SUPPORTS_CXX_STD_20 EQUAL -1
OR ${LLVM_PACKAGE_VERSION} VERSION_LESS "14.0")
set(ENABLE_CXX_STD_20_TEST_CASES 0)
@@ -34,7 +57,14 @@ else()
set(ENABLE_CXX_STD_20_TEST_CASES 1)
endif()
set(TEST_CASES
if(APPLE)
# On Apple Clang <coroutine> header is not available
list(FILTER TEST_CASE_SOURCES
EXCLUDE
REGEX ".*t00069.*")
endif(APPLE)
set(TEST_NAMES
test_util
test_model
test_cases
@@ -46,22 +76,31 @@ set(TEST_CASES
test_thread_pool_executor
test_query_driver_output_extractor)
foreach(TEST_NAME ${TEST_CASES})
add_executable(${TEST_NAME}
${TEST_NAME}.cc
$<$<STREQUAL:${TEST_NAME},test_cases>:${TEST_CASE_SOURCES}>
catch.h)
foreach(TEST_NAME ${TEST_NAMES})
add_executable(${TEST_NAME})
if(TEST_NAME STREQUAL "test_cases")
if(ENABLE_CXX_MODULES_TEST_CASES)
target_sources(${TEST_NAME} PUBLIC FILE_SET CXX_MODULES FILES
${TEST_CASE_MODULE_SOURCES})
endif(ENABLE_CXX_MODULES_TEST_CASES)
target_sources(${TEST_NAME} PUBLIC ${TEST_NAME}.cc
${TEST_CASE_SOURCES} catch.h)
else()
target_sources(${TEST_NAME} PUBLIC ${TEST_NAME}.cc catch.h)
endif(TEST_NAME STREQUAL "test_cases")
target_compile_features(${TEST_NAME} PRIVATE
$<IF:${ENABLE_CXX_STD_20_TEST_CASES},cxx_std_20,cxx_std_17>)
target_compile_definitions(${TEST_NAME} PRIVATE
$<$<EQUAL:${ENABLE_CXX_STD_20_TEST_CASES},1>:ENABLE_CXX_STD_20_TEST_CASES>)
$<$<EQUAL:${ENABLE_CXX_STD_20_TEST_CASES},1>:ENABLE_CXX_STD_20_TEST_CASES>
$<$<BOOL:${ENABLE_CXX_MODULES_TEST_CASES}>:ENABLE_CXX_MODULES_TEST_CASES>)
target_compile_options(${TEST_NAME} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
-Wno-unused-parameter -Wno-unused-variable
-Wno-attributes -Wno-nonnull -Wno-deprecated-enum-enum-conversion
${CUSTOM_COMPILE_OPTIONS}>
$<$<CXX_COMPILER_ID:MSVC>:/W1 /bigobj /wd4624>>)
$<$<CXX_COMPILER_ID:MSVC>:/MP /MD /W1 /bigobj /wd4624>>)
target_link_libraries(${TEST_NAME} PRIVATE ${CLANG_UML_TEST_LIBRARIES})
endforeach()
@@ -89,6 +128,6 @@ foreach(TEST_CONFIG_YML ${TEST_CONFIG_YMLS})
COPYONLY)
endforeach()
foreach(TEST_NAME ${TEST_CASES})
foreach(TEST_NAME ${TEST_NAMES})
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
endforeach()

View File

@@ -1,7 +1,7 @@
/**
* tests/t00002/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -93,6 +93,17 @@ TEST_CASE("t00002", "[test-case][class]")
using namespace json;
const auto &A = get_element(j, "A");
CHECK(A.has_value());
CHECK(A.value()["type"] == "class");
CHECK(A.value()["name"] == "A");
CHECK(A.value()["display_name"] == "A");
CHECK(A.value()["namespace"] == "clanguml::t00002");
CHECK(A.value()["source_location"]["file"] == "t00002.cc");
CHECK(A.value()["source_location"]["line"] == 7);
REQUIRE(HasTitle(j, "Basic class diagram example"));
REQUIRE(IsClass(j, "A"));
REQUIRE(IsClass(j, "B"));

View File

@@ -1,7 +1,7 @@
/**
* tests/t00003/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00004/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00005/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00006/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -98,10 +98,9 @@ TEST_CASE("t00006", "[test-case][class]")
REQUIRE(IsClass(j, "NN"));
REQUIRE(IsClass(j, "NNN"));
REQUIRE(IsAggregation(
j, "R", "custom_container<clanguml::t00006::E>", "e"));
REQUIRE(IsInstantiation(
j, "custom_container<T>", "custom_container<clanguml::t00006::E>"));
REQUIRE(IsAggregation(j, "R", "custom_container<E>", "e"));
REQUIRE(
IsInstantiation(j, "custom_container<T>", "custom_container<E>"));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00007/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00008/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -63,12 +63,7 @@ TEST_CASE("t00008", "[test-case][class]")
using namespace json;
#if LLVM_VERSION_MAJOR >= 16
REQUIRE(IsClassTemplate(j, "A<T,P=T,CMP=nullptr,int N=3>"));
#else
REQUIRE(IsClassTemplate(
j, "A<T,P=T,clanguml::t00008::CMP=nullptr,int N=3>"));
#endif
REQUIRE(IsClassTemplate(j, "E::nested_template<ET>"));
REQUIRE(IsClass(j, "E::nested_template<char>"));

View File

@@ -1,7 +1,7 @@
/**
* tests/t00009/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00010/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00011/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00012/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00013/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00014/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00015/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00016/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00017/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00018/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00019/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00020/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00021/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00022/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00023/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00024/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00025/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -62,8 +62,8 @@ TEST_CASE("t00025", "[test-case][class]")
REQUIRE(IsClass(j, "Target1"));
REQUIRE(IsClass(j, "Target2"));
REQUIRE(IsClassTemplate(j, "Proxy<T>"));
REQUIRE(IsDependency(j, "Proxy<clanguml::t00025::Target1>", "Target1"));
REQUIRE(IsDependency(j, "Proxy<clanguml::t00025::Target2>", "Target2"));
REQUIRE(IsDependency(j, "Proxy<Target1>", "Target1"));
REQUIRE(IsDependency(j, "Proxy<Target2>", "Target2"));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00026/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00027/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -67,12 +67,9 @@ TEST_CASE("t00027", "[test-case][class]")
REQUIRE(IsAbstractClass(j, "ShapeDecorator"));
REQUIRE(IsClassTemplate(j, "Line<T<>...>"));
REQUIRE(IsInstantiation(
j, "Line<T<>...>", "Line<clanguml::t00027::Color>"));
REQUIRE(IsInstantiation(j, "Line<T<>...>",
"Line<clanguml::t00027::Color,clanguml::t00027::Weight>"));
REQUIRE(IsAggregation(
j, "Window", "Text<clanguml::t00027::Color>", "description"));
REQUIRE(IsInstantiation(j, "Line<T<>...>", "Line<Color>"));
REQUIRE(IsInstantiation(j, "Line<T<>...>", "Line<Color,Weight>"));
REQUIRE(IsAggregation(j, "Window", "Text<Color>", "description"));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00028/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00029/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00030/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00031/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00032/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -69,9 +69,7 @@ TEST_CASE("t00032", "[test-case][class]")
using namespace json;
REQUIRE(IsBaseClass(j, "A",
"Overload<clanguml::t00032::TBase,int,clanguml::t00032::A,clanguml:"
":t00032::B,clanguml::t00032::C>"));
REQUIRE(IsBaseClass(j, "A", "Overload<TBase,int,A,B,C>"));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00033/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -61,13 +61,9 @@ TEST_CASE("t00033", "[test-case][class]")
using namespace json;
REQUIRE(IsClass(j,
"A<clanguml::t00033::B<std::unique_ptr<clanguml::t00033::C<"
"clanguml::t00033::D>>>>"));
REQUIRE(IsDependency(j,
"A<clanguml::t00033::B<std::unique_ptr<clanguml::t00033::C<"
"clanguml::t00033::D>>>>",
"B<std::unique_ptr<clanguml::t00033::C<clanguml::t00033::D>>>"));
REQUIRE(IsClass(j, "A<B<std::unique_ptr<C<D>>>>"));
REQUIRE(IsDependency(
j, "A<B<std::unique_ptr<C<D>>>>", "B<std::unique_ptr<C<D>>>"));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00034/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00035/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -17,7 +17,7 @@ struct B {
A<int> a_int;
};
}
} // namespace ns111
} // namespace ns11
} // namespace ns1
@@ -29,8 +29,8 @@ struct C { };
struct D { };
}
}
} // namespace ns22
} // namespace ns2
namespace ns3 {
namespace ns33 {

View File

@@ -1,7 +1,7 @@
/**
* tests/t00036/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -55,16 +55,20 @@ TEST_CASE("t00036", "[test-case][class]")
auto j = generate_class_json(diagram, *model);
using namespace json;
using namespace std::string_literals;
REQUIRE(IsClass(j, "ns1::ns11::A<T>"));
REQUIRE(IsClass(j, "ns1::ns11::A<int>"));
REQUIRE(IsClass(j, "ns1::ns11::ns111::B"));
REQUIRE(IsClass(j, "ns2::ns22::C"));
REQUIRE(IsEnum(j, "ns1::E"));
REQUIRE(IsPackage(j, "ns1"));
REQUIRE(IsPackage(j, "ns1::ns11"));
REQUIRE(IsPackage(j, "ns1::ns11::ns111"));
REQUIRE(IsPackage(j, "ns2"));
REQUIRE(IsNamespacePackage(j, "ns1"s));
REQUIRE(IsNamespacePackage(j, "ns1"s, "ns11"s));
REQUIRE(IsNamespacePackage(j, "ns1"s, "ns11"s, "ns111"s));
REQUIRE(IsNamespacePackage(j, "ns2"s));
REQUIRE(IsNamespacePackage(j, "ns2"s, "ns22"s));
REQUIRE(IsNamespacePackage(j, "ns3"s));
REQUIRE(IsNamespacePackage(j, "ns3"s, "ns33"s));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00037/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00038/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00039/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00040/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00041/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00042/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00043/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00044/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -75,8 +75,7 @@ TEST_CASE("t00044", "[test-case][class]")
REQUIRE(IsClassTemplate(j, "signal_handler<T,A>"));
REQUIRE(IsClassTemplate(j, "signal_handler<Ret(Args...),A>"));
REQUIRE(IsClassTemplate(j, "signal_handler<void(int),bool>"));
REQUIRE(IsClassTemplate(
j, "sink<clanguml::t00044::signal_handler<Ret(Args...),A>>"));
REQUIRE(IsClassTemplate(j, "sink<signal_handler<Ret(Args...),A>>"));
REQUIRE(IsClass(j, "R"));
save_json(config.output_directory(), diagram->name + ".json", j);

View File

@@ -1,7 +1,7 @@
/**
* tests/t00045/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00046/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00047/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00048/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00049/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00050/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00051/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00052/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00053/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00054/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00055/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00056/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00057/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00058/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -75,8 +75,7 @@ TEST_CASE("t00058", "[test-case][class]")
using namespace json;
REQUIRE(IsClass(j, "A<int,int,double,std::string>"));
REQUIRE(IsClass(
j, "B<int,std::string,int,double,clanguml::t00058::A<int,int>>"));
REQUIRE(IsClass(j, "B<int,std::string,int,double,A<int,int>>"));
save_json(config.output_directory(), diagram->name + ".json", j);
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t00059/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00060/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00061/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00062/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00063/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00064/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00065/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -38,7 +38,7 @@ TEST_CASE("t00065", "[test-case][class]")
// Check if all classes exist
REQUIRE_THAT(src, IsClass(_A("R")));
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("AImpl")));
REQUIRE_THAT(src, IsClass(_A("detail::AImpl")));
REQUIRE_THAT(src, IsEnum(_A("XYZ")));
REQUIRE_THAT(src, IsEnum(_A("ABC")));

View File

@@ -1,7 +1,7 @@
/**
* tests/t00066/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00067/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t00068/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

9
tests/t00069/.clang-uml Normal file
View File

@@ -0,0 +1,9 @@
diagrams:
t00069_class:
type: class
glob:
- t00069.cc
include:
namespaces:
- clanguml::t00069
using_namespace: clanguml::t00069

63
tests/t00069/t00069.cc Normal file
View File

@@ -0,0 +1,63 @@
#include <coroutine>
#include <optional>
namespace clanguml {
namespace t00069 {
template <typename T> struct generator {
struct promise_type;
using handle_type = std::coroutine_handle<promise_type>;
generator(handle_type h)
: h_(h)
{
}
~generator() { h_.destroy(); }
struct promise_type {
T value_;
std::exception_ptr exception_;
generator get_return_object()
{
return generator(handle_type::from_promise(*this));
}
std::suspend_always initial_suspend() { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
void unhandled_exception() { exception_ = std::current_exception(); }
template <std::convertible_to<T> From>
std::suspend_always yield_value(From &&from)
{
value_ = std::forward<From>(from);
return {};
}
void return_void() { }
};
handle_type h_;
private:
bool full_ = false;
};
class A {
public:
generator<unsigned long> iota() { co_yield counter_++; }
generator<unsigned long> seed()
{
counter_ = 42;
co_return;
}
private:
unsigned long counter_;
};
} // namespace t00069
} // namespace clanguml

87
tests/t00069/test_case.h Normal file
View File

@@ -0,0 +1,87 @@
/**
* tests/t00069/test_case.h
*
* Copyright (c) 2021-2024 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("t00069", "[test-case][class]")
{
auto [config, db] = load_config("t00069");
auto diagram = config.diagrams["t00069_class"];
REQUIRE(diagram->name == "t00069_class");
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00069_class");
{
auto src = generate_class_puml(diagram, *model);
AliasMatcher _A(src);
REQUIRE_THAT(src, StartsWith("@startuml"));
REQUIRE_THAT(src, EndsWith("@enduml\n"));
// Check if all classes exist
REQUIRE_THAT(src, IsClass(_A("A")));
// Check if class templates exist
REQUIRE_THAT(src, IsClassTemplate("generator", "T"));
// Check if all inner classes exist
REQUIRE_THAT(src,
IsInnerClass(_A("generator<T>"), _A("generator::promise_type")));
// Check if all methods exist
REQUIRE_THAT(src,
(IsMethod<Public, Coroutine>("iota", "generator<unsigned long>")));
REQUIRE_THAT(src,
(IsMethod<Public, Coroutine>("seed", "generator<unsigned long>")));
// Check if all relationships exist
REQUIRE_THAT(
src, IsDependency(_A("A"), _A("generator<unsigned long>")));
REQUIRE_THAT(src,
IsInstantiation(
_A("generator<T>"), _A("generator<unsigned long>")));
save_puml(config.output_directory(), diagram->name + ".puml", src);
}
{
auto j = generate_class_json(diagram, *model);
using namespace json;
save_json(config.output_directory(), diagram->name + ".json", j);
}
{
auto src = generate_class_mermaid(diagram, *model);
mermaid::AliasMatcher _A(src);
using mermaid::IsClass;
using mermaid::IsMethod;
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src,
(IsMethod<Public, Coroutine>("iota", "generator<unsigned long>")));
REQUIRE_THAT(src,
(IsMethod<Public, Coroutine>("seed", "generator<unsigned long>")));
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
}
}

14
tests/t00070/.clang-uml Normal file
View File

@@ -0,0 +1,14 @@
diagrams:
t00070_class:
type: class
glob:
- t00070.cc
include:
modules:
- t00070
exclude:
modules:
- t00070.lib2
module_access:
- private
using_namespace: clanguml::t00070

View File

@@ -0,0 +1,11 @@
export module t00070;
export import t00070.lib1;
export import t00070.lib2;
export namespace clanguml::t00070 {
class A {
int get() { return a; }
int a;
};
}

View File

@@ -0,0 +1,16 @@
export module t00070.lib1;
export namespace clanguml::t00070 {
class B { };
template <typename T> class BB {
T t;
};
enum class BBB { bbb1, bbb2 };
}
module :private;
namespace clanguml::t00070 {
class BBBB { };
}

View File

@@ -0,0 +1,11 @@
export module t00070.lib2;
export namespace clanguml::t00070 {
class C { };
template <typename T> class CC {
T t;
};
enum class CCC { ccc1, ccc2 };
}

15
tests/t00070/t00070.cc Normal file
View File

@@ -0,0 +1,15 @@
import t00070;
import t00070.lib1;
import t00070.lib2;
namespace clanguml {
namespace t00070 {
int tmain()
{
B b;
C c;
return 0;
}
}
}

89
tests/t00070/test_case.h Normal file
View File

@@ -0,0 +1,89 @@
/**
* tests/t00070/test_case.h
*
* Copyright (c) 2021-2024 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("t00070", "[test-case][class]")
{
auto [config, db] = load_config("t00070");
auto diagram = config.diagrams["t00070_class"];
REQUIRE(diagram->name == "t00070_class");
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00070_class");
{
auto src = generate_class_puml(diagram, *model);
AliasMatcher _A(src);
REQUIRE_THAT(src, StartsWith("@startuml"));
REQUIRE_THAT(src, EndsWith("@enduml\n"));
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("B")));
REQUIRE_THAT(src, !IsClass(_A("C")));
REQUIRE_THAT(src, IsClassTemplate("BB", "T"));
REQUIRE_THAT(src, !IsClassTemplate("CC", "T"));
REQUIRE_THAT(src, IsEnum(_A("BBB")));
REQUIRE_THAT(src, !IsClass(_A("BBBB")));
REQUIRE_THAT(src, !IsEnum(_A("CCC")));
save_puml(config.output_directory(), diagram->name + ".puml", src);
}
{
auto j = generate_class_json(diagram, *model);
using namespace json;
REQUIRE(IsClass(j, "A"));
REQUIRE(IsClass(j, "B"));
REQUIRE(!IsClass(j, "C"));
REQUIRE(InPublicModule(j, "A", "t00070"));
REQUIRE(InPublicModule(j, "B", "t00070.lib1"));
REQUIRE(!IsClass(j, "BBBB"));
save_json(config.output_directory(), diagram->name + ".json", j);
}
{
auto src = generate_class_mermaid(diagram, *model);
mermaid::AliasMatcher _A(src);
using mermaid::IsClass;
using mermaid::IsEnum;
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("B")));
REQUIRE_THAT(src, !IsClass(_A("C")));
REQUIRE_THAT(src, IsClass(_A("BB<T>")));
REQUIRE_THAT(src, !IsClass(_A("CC<T>")));
REQUIRE_THAT(src, IsEnum(_A("BBB")));
REQUIRE_THAT(src, !IsClass(_A("BBBB")));
REQUIRE_THAT(src, !IsEnum(_A("CCC")));
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
}
}

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

@@ -0,0 +1,12 @@
diagrams:
t00071_class:
type: class
glob:
- t00071.cc
include:
namespaces:
- clanguml::t00071
generate_packages: true
package_type: module
using_namespace: clanguml::t00071
using_module: t00071

View File

@@ -0,0 +1,13 @@
export module t00071.app.lib1;
export namespace clanguml::t00071 {
class B { };
template <typename T> class BB {
T t;
};
namespace detail {
enum class BBB { bbb1, bbb2 };
} // namespace detail
}

View File

@@ -0,0 +1,5 @@
export module t00071.app.lib1.mod1;
export namespace clanguml::t00071 {
class D { };
}

View File

@@ -0,0 +1,5 @@
export module t00071.app.lib1.mod2;
export namespace clanguml::t00071 {
class E { };
}

View File

@@ -0,0 +1,13 @@
export module t00071.app.lib2;
export namespace clanguml::t00071 {
class C { };
template <typename T> class CC {
T t;
};
namespace detail {
enum class CCC { ccc1, ccc2 };
}
}

View File

@@ -0,0 +1,11 @@
export module t00071.app;
export import t00071.app.lib1;
export import t00071.app.lib2;
export namespace clanguml::t00071 {
class A {
int get() { return a; }
int a;
};
}

15
tests/t00071/t00071.cc Normal file
View File

@@ -0,0 +1,15 @@
import t00071.app;
import t00071.app.lib1;
import t00071.app.lib1.mod1;
import t00071.app.lib1.mod2;
import t00071.app.lib2;
namespace clanguml {
namespace t00071 {
class R {
A *a;
B *b;
C *c;
};
}
}

76
tests/t00071/test_case.h Normal file
View File

@@ -0,0 +1,76 @@
/**
* tests/t00071/test_case.h
*
* Copyright (c) 2021-2024 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("t00071", "[test-case][class]")
{
auto [config, db] = load_config("t00071");
auto diagram = config.diagrams["t00071_class"];
REQUIRE(diagram->name == "t00071_class");
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00071_class");
{
auto src = generate_class_puml(diagram, *model);
AliasMatcher _A(src);
REQUIRE_THAT(src, StartsWith("@startuml"));
REQUIRE_THAT(src, EndsWith("@enduml\n"));
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("R")));
REQUIRE_THAT(src, IsEnum(_A("detail::BBB")));
REQUIRE_THAT(src, IsEnum(_A("detail::CCC")));
save_puml(config.output_directory(), diagram->name + ".puml", src);
}
{
auto j = generate_class_json(diagram, *model);
using namespace json;
using namespace std::string_literals;
REQUIRE(IsModulePackage(j, "app"s));
REQUIRE(IsModulePackage(j, "app"s, "lib1"s));
REQUIRE(IsModulePackage(j, "app"s, "lib1"s, "mod1"s));
REQUIRE(IsModulePackage(j, "app"s, "lib1"s, "mod2"s));
save_json(config.output_directory(), diagram->name + ".json", j);
}
{
auto src = generate_class_mermaid(diagram, *model);
mermaid::AliasMatcher _A(src);
using mermaid::IsClass;
using mermaid::IsEnum;
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("R")));
REQUIRE_THAT(src, IsEnum(_A("detail::BBB")));
REQUIRE_THAT(src, IsEnum(_A("detail::CCC")));
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
}
}

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

@@ -0,0 +1,12 @@
diagrams:
t00072_class:
type: class
glob:
- t00072.cc
generate_packages: true
package_type: module
include:
modules:
- t00072
using_module: t00072
using_namespace: clanguml::t00072

View File

@@ -0,0 +1,13 @@
export module t00072.app:lib1;
export namespace clanguml::t00072 {
class B { };
template <typename T> class BB {
T t;
};
namespace detail {
enum class BBB { bbb1, bbb2 };
} // namespace detail
}

View File

@@ -0,0 +1,5 @@
export module t00072.app:lib1.mod1;
export namespace clanguml::t00072 {
class D { };
}

View File

@@ -0,0 +1,5 @@
export module t00072.app:lib1.mod2;
export namespace clanguml::t00072 {
class E { };
}

View File

@@ -0,0 +1,13 @@
export module t00072.app:lib2;
export namespace clanguml::t00072 {
class C { };
template <typename T> class CC {
T t;
};
namespace detail {
enum class CCC { ccc1, ccc2 };
}
}

View File

@@ -0,0 +1,13 @@
export module t00072.app;
export import :lib1;
export import :lib1.mod1;
export import :lib1.mod2;
export import :lib2;
export namespace clanguml::t00072 {
class A {
int get() { return a; }
int a;
};
}

6
tests/t00072/t00072.cc Normal file
View File

@@ -0,0 +1,6 @@
import t00072.app;
namespace clanguml {
namespace t00072 {
}
}

103
tests/t00072/test_case.h Normal file
View File

@@ -0,0 +1,103 @@
/**
* tests/t00072/test_case.h
*
* Copyright (c) 2021-2024 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("t00072", "[test-case][class]")
{
auto [config, db] = load_config("t00072");
auto diagram = config.diagrams["t00072_class"];
REQUIRE(diagram->name == "t00072_class");
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00072_class");
{
auto src = generate_class_puml(diagram, *model);
AliasMatcher _A(src);
REQUIRE_THAT(src, StartsWith("@startuml"));
REQUIRE_THAT(src, EndsWith("@enduml\n"));
// Check if all classes exist
REQUIRE_THAT(src, IsPackage("app"));
REQUIRE_THAT(src, IsPackage(":lib1"));
REQUIRE_THAT(src, IsPackage(":lib2"));
REQUIRE_THAT(src, IsPackage("mod1"));
REQUIRE_THAT(src, IsPackage("mod2"));
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("C")));
REQUIRE_THAT(src, IsClassTemplate("CC", "T"));
REQUIRE_THAT(src, IsEnum(_A("detail::CCC")));
REQUIRE_THAT(src, IsClass(_A("B")));
REQUIRE_THAT(src, IsClassTemplate("BB", "T"));
REQUIRE_THAT(src, IsEnum(_A("detail::BBB")));
REQUIRE_THAT(src, IsClass(_A("D")));
REQUIRE_THAT(src, IsClass(_A("E")));
save_puml(config.output_directory(), diagram->name + ".puml", src);
}
{
auto j = generate_class_json(diagram, *model);
using namespace json;
using namespace std::string_literals;
REQUIRE(IsClass(j, "A"));
REQUIRE(IsClass(j, "B"));
REQUIRE(IsClass(j, "C"));
REQUIRE(IsClass(j, "D"));
REQUIRE(IsEnum(j, "detail::CCC"));
REQUIRE(IsEnum(j, "detail::BBB"));
REQUIRE(IsModulePackage(j, "app"s));
REQUIRE(IsModulePackage(j, "app"s, ":lib1"s));
REQUIRE(IsModulePackage(j, "app"s, ":lib1"s, "mod1"s));
REQUIRE(IsModulePackage(j, "app"s, ":lib1"s, "mod2"s));
REQUIRE(IsModulePackage(j, "app"s, ":lib2"s));
save_json(config.output_directory(), diagram->name + ".json", j);
}
{
auto src = generate_class_mermaid(diagram, *model);
mermaid::AliasMatcher _A(src);
using mermaid::IsClass;
using mermaid::IsEnum;
REQUIRE_THAT(src, IsClass(_A("A")));
REQUIRE_THAT(src, IsClass(_A("C")));
REQUIRE_THAT(src, IsClass(_A("CC<T>")));
REQUIRE_THAT(src, IsEnum(_A("detail::CCC")));
REQUIRE_THAT(src, IsClass(_A("B")));
REQUIRE_THAT(src, IsClass(_A("BB<T>")));
REQUIRE_THAT(src, IsEnum(_A("detail::BBB")));
REQUIRE_THAT(src, IsClass(_A("D")));
REQUIRE_THAT(src, IsClass(_A("E")));
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
}
}

View File

@@ -1,7 +1,7 @@
/**
* tests/t20001/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.
@@ -58,6 +58,28 @@ TEST_CASE("t20001", "[test-case][sequence]")
using namespace json;
const auto &A = get_participant(j, "A");
CHECK(A.has_value());
CHECK(A.value()["type"] == "class");
CHECK(A.value()["name"] == "A");
CHECK(A.value()["display_name"] == "A");
CHECK(A.value()["namespace"] == "clanguml::t20001");
CHECK(A.value()["source_location"]["file"] == "t20001.cc");
CHECK(A.value()["source_location"]["line"] == 13);
const auto &tmain = get_participant(j, "tmain()");
CHECK(tmain.has_value());
CHECK(tmain.value()["type"] == "function");
CHECK(tmain.value()["name"] == "tmain");
CHECK(tmain.value()["display_name"] == "tmain()");
CHECK(tmain.value()["namespace"] == "clanguml::t20001");
CHECK(tmain.value()["source_location"]["file"] == "t20001.cc");
CHECK(tmain.value()["source_location"]["line"] == 61);
REQUIRE(HasTitle(j, "Basic sequence diagram example"));
REQUIRE(IsFunctionParticipant(j, "tmain()"));
@@ -76,6 +98,7 @@ TEST_CASE("t20001", "[test-case][sequence]")
save_json(config.output_directory(), diagram->name + ".json", j);
}
{
auto src = generate_sequence_mermaid(diagram, *model);
mermaid::SequenceDiagramAliasMatcher _A(src);

View File

@@ -1,7 +1,7 @@
/**
* tests/t20002/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t20003/test_case.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t20004/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t20005/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

View File

@@ -1,7 +1,7 @@
/**
* tests/t20006/test_case.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
* Copyright (c) 2021-2024 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.

Some files were not shown because too many files have changed in this diff Show More