Added support for try/catch statements in sequence diagrams
This commit is contained in:
14
tests/t20023/.clang-uml
Normal file
14
tests/t20023/.clang-uml
Normal file
@@ -0,0 +1,14 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t20023_sequence:
|
||||
type: sequence
|
||||
glob:
|
||||
- ../../tests/t20023/t20023.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t20023
|
||||
using_namespace:
|
||||
- clanguml::t20023
|
||||
start_from:
|
||||
- function: "clanguml::t20023::tmain()"
|
||||
40
tests/t20023/t20023.cc
Normal file
40
tests/t20023/t20023.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <stdexcept>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t20023 {
|
||||
|
||||
struct A {
|
||||
int a1() { return 1; }
|
||||
int a2() { return 2; }
|
||||
int a3() { return 3; }
|
||||
int a4() { return 3; }
|
||||
|
||||
int a()
|
||||
{
|
||||
try {
|
||||
return a1();
|
||||
}
|
||||
catch (std::runtime_error &) {
|
||||
return a2();
|
||||
}
|
||||
catch (std::logic_error &) {
|
||||
return a3();
|
||||
}
|
||||
catch (...) {
|
||||
return a4();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int tmain()
|
||||
{
|
||||
A a;
|
||||
|
||||
int result{};
|
||||
|
||||
result = a.a();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
tests/t20023/test_case.h
Normal file
46
tests/t20023/test_case.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* tests/t20023/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("t20023", "[test-case][sequence]")
|
||||
{
|
||||
auto [config, db] = load_config("t20023");
|
||||
|
||||
auto diagram = config.diagrams["t20023_sequence"];
|
||||
|
||||
REQUIRE(diagram->name == "t20023_sequence");
|
||||
|
||||
auto model = generate_sequence_diagram(*db, diagram);
|
||||
|
||||
REQUIRE(model->name() == "t20023_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("A"), "a1()"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("A"), _A("A"), "a2()"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("A"), _A("A"), "a3()"));
|
||||
REQUIRE_THAT(puml, HasCall(_A("A"), _A("A"), "a4()"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
@@ -269,6 +269,7 @@ using namespace clanguml::test::matchers;
|
||||
#include "t20020/test_case.h"
|
||||
#include "t20021/test_case.h"
|
||||
#include "t20022/test_case.h"
|
||||
#include "t20023/test_case.h"
|
||||
|
||||
///
|
||||
/// Package diagram tests
|
||||
|
||||
@@ -214,6 +214,9 @@ test_cases:
|
||||
- name: t20022
|
||||
title: Forward class declaration sequence diagram test case
|
||||
description:
|
||||
- name: t20023
|
||||
title: Try/catch statement sequence diagram test case
|
||||
description:
|
||||
Package diagrams:
|
||||
- name: t30001
|
||||
title: Basic package diagram test case
|
||||
|
||||
Reference in New Issue
Block a user