Added variadic class template sequence diagram test case

This commit is contained in:
Bartek Kryza
2022-11-27 14:24:12 +01:00
parent e586c9d062
commit b36355352d
6 changed files with 95 additions and 32 deletions

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

@@ -0,0 +1,14 @@
compilation_database_dir: ..
output_directory: puml
diagrams:
t20007_sequence:
type: sequence
glob:
- ../../tests/t20007/t20007.cc
include:
namespaces:
- clanguml::t20007
using_namespace:
- clanguml::t20007
start_from:
- function: "clanguml::t20007::tmain()"

25
tests/t20007/t20007.cc Normal file
View File

@@ -0,0 +1,25 @@
#include <string>
#include <utility>
namespace clanguml {
namespace t20007 {
template <typename First, typename... Args> struct Adder {
First add(First &&arg, Args &&...args) { return (arg + ... + args); }
};
void tmain()
{
using namespace std::string_literals;
Adder<int, int> adder1;
Adder<int, float, double> adder2;
Adder<std::string, std::string, std::string> adder3;
[[maybe_unused]] auto res1 = adder1.add(2, 2);
[[maybe_unused]] auto res2 = adder2.add(1, 2.0, 3.0);
[[maybe_unused]] auto res3 = adder3.add("one"s, "two"s, "three"s);
}
}
}

47
tests/t20007/test_case.h Normal file
View File

@@ -0,0 +1,47 @@
/**
* tests/t20007/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("t20007", "[test-case][sequence]")
{
auto [config, db] = load_config("t20007");
auto diagram = config.diagrams["t20007_sequence"];
REQUIRE(diagram->name == "t20007_sequence");
auto model = generate_sequence_diagram(*db, diagram);
REQUIRE(model->name() == "t20007_sequence");
auto puml = generate_sequence_puml(diagram, *model);
AliasMatcher _A(puml);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
// Check if all calls exist
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("Adder<int,int>"), "add"));
REQUIRE_THAT(
puml, HasCall(_A("tmain()"), _A("Adder<int,float,double>"), "add"));
REQUIRE_THAT(puml,
HasCall(_A("tmain()"), _A("Adder<std::string,std::string,std::string>"),
"add"));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
}

View File

@@ -253,6 +253,7 @@ using namespace clanguml::test::matchers;
#include "t20004/test_case.h"
#include "t20005/test_case.h"
#include "t20006/test_case.h"
#include "t20007/test_case.h"
///
/// Package diagram tests

View File

@@ -166,6 +166,9 @@ test_cases:
- name: t20006
title: Class template specialization basic sequence diagram
description:
- name: t20007
title: Class template variadic argument list sequence diagram
description:
Package diagrams:
- name: t30001
title: Basic package diagram test case