Added forward class declaration sequence diagram test case
This commit is contained in:
14
tests/t20022/.clang-uml
Normal file
14
tests/t20022/.clang-uml
Normal file
@@ -0,0 +1,14 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t20022_sequence:
|
||||
type: sequence
|
||||
glob:
|
||||
- ../../tests/t20022/t20022.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t20022
|
||||
using_namespace:
|
||||
- clanguml::t20022
|
||||
start_from:
|
||||
- function: "clanguml::t20022::tmain()"
|
||||
37
tests/t20022/t20022.cc
Normal file
37
tests/t20022/t20022.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <memory>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t20022 {
|
||||
class B;
|
||||
|
||||
class A {
|
||||
public:
|
||||
A(std::unique_ptr<B> b);
|
||||
|
||||
void a();
|
||||
|
||||
std::unique_ptr<B> b_;
|
||||
};
|
||||
|
||||
class B {
|
||||
public:
|
||||
void b() { }
|
||||
};
|
||||
|
||||
A::A(std::unique_ptr<B> b)
|
||||
: b_{std::move(b)}
|
||||
{
|
||||
}
|
||||
|
||||
void A::a() { b_->b(); }
|
||||
|
||||
int tmain()
|
||||
{
|
||||
A a{std::make_unique<B>()};
|
||||
|
||||
a.a();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
tests/t20022/test_case.h
Normal file
43
tests/t20022/test_case.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* tests/t20022/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("t20022", "[test-case][sequence]")
|
||||
{
|
||||
auto [config, db] = load_config("t20022");
|
||||
|
||||
auto diagram = config.diagrams["t20022_sequence"];
|
||||
|
||||
REQUIRE(diagram->name == "t20022_sequence");
|
||||
|
||||
auto model = generate_sequence_diagram(*db, diagram);
|
||||
|
||||
REQUIRE(model->name() == "t20022_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("A"), "a()"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("A"), _A("B"), "b()"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
@@ -268,6 +268,7 @@ using namespace clanguml::test::matchers;
|
||||
#include "t20019/test_case.h"
|
||||
#include "t20020/test_case.h"
|
||||
#include "t20021/test_case.h"
|
||||
#include "t20022/test_case.h"
|
||||
|
||||
///
|
||||
/// Package diagram tests
|
||||
|
||||
@@ -211,6 +211,9 @@ test_cases:
|
||||
- name: t20021
|
||||
title: Loop statements sequence diagram test case
|
||||
description:
|
||||
- name: t20022
|
||||
title: Forward class declaration sequence diagram test case
|
||||
description:
|
||||
Package diagrams:
|
||||
- name: t30001
|
||||
title: Basic package diagram test case
|
||||
|
||||
@@ -56,8 +56,8 @@ CLASS_DIAGRAM_TEST_CASE_EXAMPLES = """
|
||||
|
||||
SEQUENCE_DIAGRAM_TEST_CASE_EXAMPLES = """
|
||||
// Check if all calls exist
|
||||
//REQUIRE_THAT(puml, HasCall("A", "log_result"));
|
||||
//REQUIRE_THAT(puml, HasCallWithResponse("B", "A", "add3"));
|
||||
//REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("A"), "a()"));
|
||||
//REQUIRE_THAT(puml, HasCall(_A("A"), "a()"));
|
||||
"""
|
||||
|
||||
PACKAGE_DIAGRAM_TEST_CASE_EXAMPLES = """
|
||||
|
||||
Reference in New Issue
Block a user