Added test case for configurable type aliases
This commit is contained in:
15
tests/t00049/.clang-uml
Normal file
15
tests/t00049/.clang-uml
Normal file
@@ -0,0 +1,15 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t00049_class:
|
||||
type: class
|
||||
using_namespace: clanguml::t00049
|
||||
template_aliases:
|
||||
"std::vector<std::string>": string_vector
|
||||
"std::basic_string<char>": thestring
|
||||
"std::map<int,int>": intmap
|
||||
glob:
|
||||
- ../../tests/t00049/t00049.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00049
|
||||
23
tests/t00049/t00049.cc
Normal file
23
tests/t00049/t00049.cc
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t00049 {
|
||||
template <typename T> struct A {
|
||||
T a;
|
||||
|
||||
T &get_a() { return a; }
|
||||
};
|
||||
|
||||
struct R {
|
||||
A<std::basic_string<char>> a_string;
|
||||
A<std::vector<std::string>> a_vector_string;
|
||||
A<std::map<int, int>> a_int_map;
|
||||
|
||||
A<std::map<int, int>> get_int_map() { return a_int_map; }
|
||||
|
||||
void set_int_map(A<std::map<int, int>> &&int_map) { a_int_map = int_map; }
|
||||
};
|
||||
}
|
||||
}
|
||||
62
tests/t00049/test_case.h
Normal file
62
tests/t00049/test_case.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* tests/t00049/test_case.h
|
||||
*
|
||||
* 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("t00049", "[test-case][class]")
|
||||
{
|
||||
auto [config, db] = load_config("t00049");
|
||||
|
||||
auto diagram = config.diagrams["t00049_class"];
|
||||
|
||||
REQUIRE(diagram->name == "t00049_class");
|
||||
|
||||
auto model = generate_class_diagram(*db, diagram);
|
||||
|
||||
REQUIRE(model->name() == "t00049_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("R")));
|
||||
|
||||
// Check if class templates exist
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T"));
|
||||
|
||||
// Check if all methods exist
|
||||
REQUIRE_THAT(puml, (IsMethod<Public>("get_int_map", "A<intmap>")));
|
||||
REQUIRE_THAT(puml,
|
||||
(IsMethod<Public>("set_int_map", "void", "A<intmap> && int_map")));
|
||||
|
||||
// Check if all fields exist
|
||||
REQUIRE_THAT(puml, (IsField<Public>("a_string", "A<thestring>")));
|
||||
REQUIRE_THAT(
|
||||
puml, (IsField<Public>("a_vector_string", "A<string_vector>")));
|
||||
REQUIRE_THAT(puml, (IsField<Public>("a_int_map", "A<intmap>")));
|
||||
|
||||
// Check if all relationships exist
|
||||
REQUIRE_THAT(
|
||||
puml, IsInstantiation(_A("A<T>"), _A("A<std::vector<thestring>>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T>"), _A("A<thestring>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T>"), _A("A<intmap>")));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
@@ -191,9 +191,9 @@ void save_puml(const std::string &path, const std::string &puml)
|
||||
|
||||
using namespace clanguml::test::matchers;
|
||||
|
||||
//
|
||||
// Class diagram tests
|
||||
//
|
||||
///
|
||||
/// Class diagram tests
|
||||
///
|
||||
#include "t00002/test_case.h"
|
||||
#include "t00003/test_case.h"
|
||||
#include "t00004/test_case.h"
|
||||
@@ -241,13 +241,14 @@ using namespace clanguml::test::matchers;
|
||||
#include "t00046/test_case.h"
|
||||
#include "t00047/test_case.h"
|
||||
#include "t00048/test_case.h"
|
||||
#include "t00049/test_case.h"
|
||||
|
||||
////
|
||||
//// Sequence diagram tests
|
||||
////
|
||||
#include "t20001/test_case.h"
|
||||
#include "t20002/test_case.h"
|
||||
//
|
||||
|
||||
////
|
||||
//// Package diagram tests
|
||||
////
|
||||
@@ -259,14 +260,14 @@ using namespace clanguml::test::matchers;
|
||||
#include "t30006/test_case.h"
|
||||
#include "t30007/test_case.h"
|
||||
#include "t30008/test_case.h"
|
||||
//
|
||||
|
||||
////
|
||||
//// Include diagram tests
|
||||
////
|
||||
#include "t40001/test_case.h"
|
||||
#include "t40002/test_case.h"
|
||||
#include "t40003/test_case.h"
|
||||
//
|
||||
|
||||
////
|
||||
//// Other tests (e.g. configuration file)
|
||||
////
|
||||
|
||||
@@ -141,6 +141,9 @@ test_cases:
|
||||
- name: t00048
|
||||
title: Test case for unique entity id with multiple translation units
|
||||
description:
|
||||
- name: t00049
|
||||
title: Test case configurable type aliases
|
||||
description:
|
||||
Sequence diagrams:
|
||||
- name: t20001
|
||||
title: Basic sequence diagram test case
|
||||
|
||||
Reference in New Issue
Block a user