Added option include_system_headers to enable processing of system headers
This commit is contained in:
14
tests/t00080/.clang-uml
Normal file
14
tests/t00080/.clang-uml
Normal file
@@ -0,0 +1,14 @@
|
||||
diagrams:
|
||||
t00080_class:
|
||||
type: class
|
||||
filter_mode: advanced
|
||||
include_system_headers: true
|
||||
glob:
|
||||
- t00080.cc
|
||||
include:
|
||||
anyof:
|
||||
namespaces:
|
||||
- clanguml::t00080
|
||||
elements:
|
||||
- std::thread
|
||||
using_namespace: clanguml::t00080
|
||||
24
tests/t00080/t00080.cc
Normal file
24
tests/t00080/t00080.cc
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <thread>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t00080 {
|
||||
|
||||
class Worker : public std::thread {
|
||||
public:
|
||||
using std::thread::thread;
|
||||
|
||||
~Worker()
|
||||
{
|
||||
if (this->joinable()) {
|
||||
this->join();
|
||||
}
|
||||
}
|
||||
|
||||
void start(int delay) { }
|
||||
};
|
||||
|
||||
struct R {
|
||||
Worker *w;
|
||||
};
|
||||
}
|
||||
}
|
||||
35
tests/t00080/test_case.h
Normal file
35
tests/t00080/test_case.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* tests/t00080/test_case.h
|
||||
*
|
||||
* Copyright (c) 2021-2024 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("t00080")
|
||||
{
|
||||
using namespace clanguml::test;
|
||||
using namespace std::string_literals;
|
||||
|
||||
auto [config, db, diagram, model] =
|
||||
CHECK_CLASS_MODEL("t00080", "t00080_class");
|
||||
|
||||
CHECK_CLASS_DIAGRAM(*config, diagram, *model, [](const auto &src) {
|
||||
REQUIRE(IsClass(src, "Worker"));
|
||||
REQUIRE(IsClass(src, "R"));
|
||||
REQUIRE(IsClass(src, "std::thread"));
|
||||
REQUIRE(!IsClass(src, "std::jthread"));
|
||||
|
||||
REQUIRE(IsAssociation<Public>(src, "R", "Worker", "w"));
|
||||
});
|
||||
}
|
||||
@@ -553,6 +553,7 @@ void CHECK_INCLUDE_DIAGRAM(const clanguml::config::config &config,
|
||||
#include "t00077/test_case.h"
|
||||
#include "t00078/test_case.h"
|
||||
#include "t00079/test_case.h"
|
||||
#include "t00080/test_case.h"
|
||||
|
||||
///
|
||||
/// Sequence diagram tests
|
||||
|
||||
@@ -234,6 +234,9 @@ test_cases:
|
||||
- name: t00079
|
||||
title: Test case for context diagram exclude filter with relationships option
|
||||
description:
|
||||
- name: t00080
|
||||
title: Test case for including elements from system headers
|
||||
description:
|
||||
Sequence diagrams:
|
||||
- name: t20001
|
||||
title: Basic sequence diagram test case
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
compilation_database_dir: debug
|
||||
output_directory: output
|
||||
filter_mode: advanced
|
||||
diagrams:
|
||||
anyof_test:
|
||||
type: class
|
||||
@@ -7,7 +8,6 @@ diagrams:
|
||||
glob:
|
||||
- src/**/*.cc
|
||||
- src/**/*.h
|
||||
filter_mode: advanced
|
||||
include:
|
||||
anyof:
|
||||
namespaces:
|
||||
@@ -17,4 +17,12 @@ diagrams:
|
||||
exclude:
|
||||
anyof:
|
||||
namespaces:
|
||||
- ns1::ns2::detail
|
||||
- ns1::ns2::detail
|
||||
modules_test:
|
||||
type: class
|
||||
include:
|
||||
anyof:
|
||||
modules:
|
||||
- mod1::mod2
|
||||
namespaces:
|
||||
- ns1::ns2
|
||||
@@ -28,15 +28,14 @@
|
||||
#include "sequence_diagram/model/diagram.h"
|
||||
|
||||
#include <filesystem>
|
||||
using clanguml::common::model::diagram_filter;
|
||||
using clanguml::common::model::diagram_filter_factory;
|
||||
using clanguml::common::model::namespace_;
|
||||
using clanguml::common::model::source_file;
|
||||
using clanguml::config::filter_mode_t;
|
||||
|
||||
TEST_CASE("Test advanced diagram filter anyof")
|
||||
{
|
||||
using clanguml::common::model::diagram_filter;
|
||||
using clanguml::common::model::diagram_filter_factory;
|
||||
using clanguml::common::model::namespace_;
|
||||
using clanguml::common::model::source_file;
|
||||
using clanguml::config::filter_mode_t;
|
||||
|
||||
auto cfg =
|
||||
clanguml::config::load("./test_config_data/filters_advanced.yml");
|
||||
|
||||
@@ -61,6 +60,39 @@ TEST_CASE("Test advanced diagram filter anyof")
|
||||
CHECK_FALSE(filter.should_include(namespace_{"ns1::ns2::detail"}));
|
||||
}
|
||||
|
||||
TEST_CASE("Test advanced diagram filter modules")
|
||||
{
|
||||
auto cfg =
|
||||
clanguml::config::load("./test_config_data/filters_advanced.yml");
|
||||
|
||||
auto &config = *cfg.diagrams["modules_test"];
|
||||
clanguml::include_diagram::model::diagram diagram;
|
||||
|
||||
auto filter_ptr = diagram_filter_factory::create(diagram, config);
|
||||
diagram_filter &filter = *filter_ptr;
|
||||
|
||||
CHECK(config.filter_mode() == filter_mode_t::advanced);
|
||||
CHECK(filter.should_include(namespace_{"ns1::ns2"}));
|
||||
CHECK_FALSE(filter.should_include(namespace_{"std::string"}));
|
||||
|
||||
clanguml::common::model::element std_string{{}};
|
||||
std_string.set_namespace(namespace_{"std"});
|
||||
std_string.set_name("string");
|
||||
|
||||
CHECK_FALSE(filter.should_include(std_string));
|
||||
|
||||
CHECK(filter.should_include(namespace_{"ns1"}));
|
||||
|
||||
clanguml::common::model::element e1{{}};
|
||||
e1.set_module("mod1::mod2");
|
||||
e1.set_namespace(namespace_{"ns5::ns6"});
|
||||
e1.set_name("ClassA");
|
||||
CHECK(filter.should_include(e1));
|
||||
|
||||
e1.set_module("mod1::mod3");
|
||||
CHECK_FALSE(filter.should_include(e1));
|
||||
}
|
||||
|
||||
///
|
||||
/// Main test function
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user