Added test case for inline diagram in config without code

This commit is contained in:
Bartek Kryza
2021-03-12 22:22:27 +01:00
parent 0ee5eeb619
commit 520071f5b3
8 changed files with 69 additions and 15 deletions

20
tests/t00000/.clanguml Normal file
View File

@@ -0,0 +1,20 @@
compilation_database_dir: ..
output_directory: puml
diagrams:
t00000_class:
type: class
plantuml:
before:
- 'class "Foo" as C_001'
- 'class C_001 {'
- ' +int value'
- '}'
- 'C_001 <|-- ArrayList'
- 'note top of C_001: This is a very important class.'
- 'note "This is a\nfloating note" as N1'
- 'note "This note is connected\nto several objects." as N2'
- 'C_001 .. N2'
- 'N2 .. ArrayList'
- 'class "Boo" as C_002'
- 'class C_002 {'
- '}'

0
tests/t00000/t00000.cc Normal file
View File

42
tests/t00000/test_case.h Normal file
View File

@@ -0,0 +1,42 @@
/**
* tests/t00000/test_case.cc
*
* Copyright (c) 2021 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("Test t00000", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00000");
auto diagram = config.diagrams["t00000_class"];
auto model = generate_class_diagram(db, diagram);
REQUIRE(model.name == "t00000_class");
auto puml = generate_class_puml(diagram, model);
AliasMatcher _A(puml);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, IsClass(_A("Foo")));
REQUIRE_THAT(puml, IsClass(_A("Boo")));
save_puml(
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
}

View File

@@ -10,8 +10,3 @@ diagrams:
include:
namespaces:
- clanguml::t00002
plantuml:
before:
- "' t00002 test class diagram"
after:
- 'note over "A": A class'

View File

@@ -10,8 +10,3 @@ diagrams:
include:
namespaces:
- clanguml::t00003
plantuml:
before:
- "' t00003 test class members"
after:
- 'note over "A": A class'

View File

@@ -12,8 +12,3 @@ diagrams:
include:
namespaces:
- clanguml::t00004
plantuml:
before:
- "' t00004 test class members"
after:
- 'note over "A": A class'

View File

@@ -113,6 +113,7 @@ using clanguml::test::matchers::Protected;
using clanguml::test::matchers::Public;
using clanguml::test::matchers::Static;
#include "t00000/test_case.h"
#include "t00001/test_case.h"
#include "t00002/test_case.h"
#include "t00003/test_case.h"