Added basic class access and type specifiers generation
This commit is contained in:
@@ -8,6 +8,7 @@ set(CLANG_UML_TEST_CASES_SRC
|
||||
test_cases.cc
|
||||
t00001/t00001.cc
|
||||
t00002/t00002.cc
|
||||
t00003/t00003.cc
|
||||
)
|
||||
set(CLANG_UML_TEST_CASES_HEADER
|
||||
catch.h
|
||||
@@ -25,5 +26,6 @@ target_link_libraries(test_cases
|
||||
|
||||
configure_file(t00001/.clanguml t00001/.clanguml COPYONLY)
|
||||
configure_file(t00002/.clanguml t00002/.clanguml COPYONLY)
|
||||
configure_file(t00003/.clanguml t00003/.clanguml COPYONLY)
|
||||
|
||||
add_test(NAME test_cases COMMAND test_cases)
|
||||
|
||||
17
tests/t00003/.clanguml
Normal file
17
tests/t00003/.clanguml
Normal file
@@ -0,0 +1,17 @@
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t00003_class:
|
||||
type: class
|
||||
glob:
|
||||
- ../../tests/t00003/t00003.cc
|
||||
using_namespace:
|
||||
- clanguml::t00003
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00003
|
||||
plantuml:
|
||||
before:
|
||||
- "' t00003 test class members"
|
||||
after:
|
||||
- 'note over "A": A class'
|
||||
28
tests/t00003/t00003.cc
Normal file
28
tests/t00003/t00003.cc
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace clanguml {
|
||||
namespace t00003 {
|
||||
|
||||
class A {
|
||||
public:
|
||||
A() = default;
|
||||
A(A &&) = default;
|
||||
A(const A &) = default;
|
||||
virtual ~A() = default;
|
||||
|
||||
void basic_method() {}
|
||||
static int static_method() { return 0; }
|
||||
void const_method() const {}
|
||||
|
||||
int public_member;
|
||||
|
||||
protected:
|
||||
void protected_method() {}
|
||||
|
||||
int protected_member;
|
||||
|
||||
private:
|
||||
void private_method() {}
|
||||
|
||||
int private_member;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -160,3 +160,48 @@ TEST_CASE("Test t00002", "[unit-test]")
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
|
||||
TEST_CASE("Test t00003", "[unit-test]")
|
||||
{
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
|
||||
auto [config, db] = load_config("t00003");
|
||||
|
||||
auto diagram = config.diagrams["t00003_class"];
|
||||
|
||||
REQUIRE(diagram->name == "t00003_class");
|
||||
|
||||
REQUIRE(diagram->include.namespaces.size() == 1);
|
||||
REQUIRE_THAT(diagram->include.namespaces,
|
||||
VectorContains(std::string{"clanguml::t00003"}));
|
||||
|
||||
REQUIRE(diagram->exclude.namespaces.size() == 0);
|
||||
|
||||
REQUIRE(diagram->should_include("clanguml::t00003::A"));
|
||||
|
||||
auto model = generate_class_diagram(db, diagram);
|
||||
|
||||
REQUIRE(model.name == "t00003_class");
|
||||
|
||||
auto puml = generate_class_puml(diagram, model);
|
||||
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
REQUIRE_THAT(puml, Contains("class A"));
|
||||
|
||||
REQUIRE_THAT(puml, Contains("+ A() = default"));
|
||||
REQUIRE_THAT(puml, Contains("+ A() = default"));
|
||||
REQUIRE_THAT(puml, Contains("+ A() = default"));
|
||||
REQUIRE_THAT(puml, Contains("+ ~A() = default"));
|
||||
REQUIRE_THAT(puml, Contains("+ basic_method()"));
|
||||
REQUIRE_THAT(puml, Contains("{static} +int static_method()"));
|
||||
REQUIRE_THAT(puml, Contains("+ const_method() const"));
|
||||
REQUIRE_THAT(puml, Contains("# protected_method()"));
|
||||
REQUIRE_THAT(puml, Contains("- private_method()"));
|
||||
REQUIRE_THAT(puml, Contains("+int public_member"));
|
||||
REQUIRE_THAT(puml, Contains("#int protected_member"));
|
||||
REQUIRE_THAT(puml, Contains("-int private_member"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user