Added support for class friend declarations
This commit is contained in:
12
tests/t00011/.clanguml
Normal file
12
tests/t00011/.clanguml
Normal file
@@ -0,0 +1,12 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t00011_class:
|
||||
type: class
|
||||
glob:
|
||||
- ../../tests/t00011/t00011.cc
|
||||
using_namespace:
|
||||
- clanguml::t00011
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00011
|
||||
18
tests/t00011/t00011.cc
Normal file
18
tests/t00011/t00011.cc
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace clanguml {
|
||||
namespace t00011 {
|
||||
|
||||
class B;
|
||||
|
||||
class A {
|
||||
private:
|
||||
void foo() {}
|
||||
friend class B;
|
||||
};
|
||||
|
||||
class B {
|
||||
public:
|
||||
void foo() { m_a->foo(); }
|
||||
A *m_a;
|
||||
};
|
||||
}
|
||||
}
|
||||
54
tests/t00011/test_case.h
Normal file
54
tests/t00011/test_case.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* tests/t00011/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 t00011", "[unit-test]")
|
||||
{
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
|
||||
auto [config, db] = load_config("t00011");
|
||||
|
||||
auto diagram = config.diagrams["t00011_class"];
|
||||
|
||||
REQUIRE(diagram->name == "t00011_class");
|
||||
|
||||
REQUIRE(diagram->include.namespaces.size() == 1);
|
||||
REQUIRE_THAT(diagram->include.namespaces,
|
||||
VectorContains(std::string{"clanguml::t00011"}));
|
||||
|
||||
REQUIRE(diagram->exclude.namespaces.size() == 0);
|
||||
|
||||
REQUIRE(diagram->should_include("clanguml::t00011::A"));
|
||||
REQUIRE(diagram->should_include("clanguml::t00011::B"));
|
||||
|
||||
auto model = generate_class_diagram(db, diagram);
|
||||
|
||||
REQUIRE(model.name == "t00011_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("A")));
|
||||
REQUIRE_THAT(puml, IsClass(_A("B")));
|
||||
|
||||
REQUIRE_THAT(puml, IsFriend(_A("A"), _A("B")));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
@@ -105,6 +105,7 @@ using clanguml::test::matchers::IsClassTemplate;
|
||||
using clanguml::test::matchers::IsComposition;
|
||||
using clanguml::test::matchers::IsEnum;
|
||||
using clanguml::test::matchers::IsField;
|
||||
using clanguml::test::matchers::IsFriend;
|
||||
using clanguml::test::matchers::IsInnerClass;
|
||||
using clanguml::test::matchers::IsInstantiation;
|
||||
using clanguml::test::matchers::Private;
|
||||
@@ -122,3 +123,4 @@ using clanguml::test::matchers::Static;
|
||||
#include "t00008/test_case.h"
|
||||
#include "t00009/test_case.h"
|
||||
#include "t00010/test_case.h"
|
||||
#include "t00011/test_case.h"
|
||||
|
||||
@@ -270,6 +270,13 @@ ContainsMatcher IsAssociation(std::string const &from, std::string const &to,
|
||||
fmt::format("{} --> {} : {}", from, to, label), caseSensitivity));
|
||||
}
|
||||
|
||||
ContainsMatcher IsFriend(std::string const &from, std::string const &to,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
return ContainsMatcher(CasedString(
|
||||
fmt::format("{} <.. {} : <<friend>>", from, to), caseSensitivity));
|
||||
}
|
||||
|
||||
ContainsMatcher IsComposition(std::string const &from, std::string const &to,
|
||||
std::string const &label,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
|
||||
Reference in New Issue
Block a user