Ported remaining tests from Catch to doctest (#266)

This commit is contained in:
Bartek Kryza
2024-05-20 22:32:10 +02:00
parent 387b46f683
commit 31100af689
9 changed files with 93 additions and 20446 deletions

View File

@@ -103,9 +103,9 @@ foreach(TEST_NAME ${TEST_NAMES})
${TEST_CASE_MODULE_SOURCES}) ${TEST_CASE_MODULE_SOURCES})
endif(ENABLE_CXX_MODULES_TEST_CASES) endif(ENABLE_CXX_MODULES_TEST_CASES)
target_sources(${TEST_NAME} PUBLIC ${TEST_NAME}.cc target_sources(${TEST_NAME} PUBLIC ${TEST_NAME}.cc
${TEST_CASE_SOURCES} catch.h) ${TEST_CASE_SOURCES})
else() else()
target_sources(${TEST_NAME} PUBLIC ${TEST_NAME}.cc catch.h) target_sources(${TEST_NAME} PUBLIC ${TEST_NAME}.cc)
endif(TEST_NAME STREQUAL "test_cases") endif(TEST_NAME STREQUAL "test_cases")
target_compile_features(${TEST_NAME} PRIVATE target_compile_features(${TEST_NAME} PRIVATE

File diff suppressed because it is too large Load Diff

View File

@@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define CATCH_CONFIG_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "cli/cli_handler.h" #include "cli/cli_handler.h"
#include "version.h" #include "version.h"
#include "catch.h" #include "doctest/doctest.h"
#include <spdlog/sinks/ostream_sink.h> #include <spdlog/sinks/ostream_sink.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
@@ -32,7 +32,7 @@ std::shared_ptr<spdlog::logger> make_sstream_logger(std::ostream &ostr)
"clanguml-logger", std::move(oss_sink)); "clanguml-logger", std::move(oss_sink));
} }
TEST_CASE("Test cli handler print_version", "[unit-test]") TEST_CASE("Test cli handler print_version")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;
@@ -52,7 +52,7 @@ TEST_CASE("Test cli handler print_version", "[unit-test]")
"clang-uml {}", clanguml::version::CLANG_UML_VERSION)) == 0); "clang-uml {}", clanguml::version::CLANG_UML_VERSION)) == 0);
} }
TEST_CASE("Test cli handler print_config", "[unit-test]") TEST_CASE("Test cli handler print_config")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;
@@ -73,7 +73,7 @@ TEST_CASE("Test cli handler print_config", "[unit-test]")
REQUIRE(doc["diagrams"]["class_main"]); REQUIRE(doc["diagrams"]["class_main"]);
} }
TEST_CASE("Test cli handler print_diagrams_list", "[unit-test]") TEST_CASE("Test cli handler print_diagrams_list")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;
@@ -97,7 +97,7 @@ TEST_CASE("Test cli handler print_diagrams_list", "[unit-test]")
)"); )");
} }
TEST_CASE("Test cli handler print_diagram_templates", "[unit-test]") TEST_CASE("Test cli handler print_diagram_templates")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;
@@ -123,7 +123,7 @@ TEST_CASE("Test cli handler print_diagram_templates", "[unit-test]")
)"); )");
} }
TEST_CASE("Test cli handler print_diagram_template", "[unit-test]") TEST_CASE("Test cli handler print_diagram_template")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;
@@ -158,8 +158,7 @@ TEST_CASE("Test cli handler print_diagram_template", "[unit-test]")
)"); )");
} }
TEST_CASE( TEST_CASE("Test cli handler add_compile_flag and remove_compile_flag")
"Test cli handler add_compile_flag and remove_compile_flag", "[unit-test]")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;
@@ -185,8 +184,7 @@ TEST_CASE(
REQUIRE(contains(cli.config.remove_compile_flags(), "-I/usr/include")); REQUIRE(contains(cli.config.remove_compile_flags(), "-I/usr/include"));
} }
TEST_CASE( TEST_CASE("Test cli handler puml config inheritance with render cmd")
"Test cli handler puml config inheritance with render cmd", "[unit-test]")
{ {
using clanguml::cli::cli_flow_t; using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler; using clanguml::cli::cli_handler;

View File

@@ -15,16 +15,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define CATCH_CONFIG_RUNNER #define DOCTEST_CONFIG_IMPLEMENT
#define CATCH_CONFIG_CONSOLE_WIDTH 512
#include "catch.h" #include "doctest/doctest.h"
#include "cli/cli_handler.h" #include "cli/cli_handler.h"
#include "common/compilation_database.h" #include "common/compilation_database.h"
#include "util/util.h" #include "util/util.h"
#include "catch.h"
#include <spdlog/sinks/ostream_sink.h> #include <spdlog/sinks/ostream_sink.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
@@ -35,7 +33,7 @@ std::shared_ptr<spdlog::logger> make_sstream_logger(std::ostream &ostr)
"clanguml-logger", std::move(oss_sink)); "clanguml-logger", std::move(oss_sink));
} }
TEST_CASE("Test compilation_database should work", "[unit-test]") TEST_CASE("Test compilation_database should work")
{ {
using clanguml::common::compilation_database; using clanguml::common::compilation_database;
using clanguml::common::compilation_database_ptr; using clanguml::common::compilation_database_ptr;
@@ -82,7 +80,7 @@ TEST_CASE("Test compilation_database should work", "[unit-test]")
} }
} }
TEST_CASE("Test compilation_database should throw", "[unit-test]") TEST_CASE("Test compilation_database should throw")
{ {
using clanguml::common::compilation_database; using clanguml::common::compilation_database;
using clanguml::common::compilation_database_ptr; using clanguml::common::compilation_database_ptr;
@@ -102,30 +100,23 @@ TEST_CASE("Test compilation_database should throw", "[unit-test]")
/// ///
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Catch::Session session; doctest::Context context;
using namespace Catch::clara;
bool debug_log{false}; context.applyCommandLine(argc, argv);
auto cli = session.cli() |
Opt(debug_log, "debug_log")["-u"]["--debug-log"]("Enable debug logs");
session.cli(cli);
int returnCode = session.applyCommandLine(argc, argv);
if (returnCode != 0)
return returnCode;
clanguml::cli::cli_handler clih; clanguml::cli::cli_handler clih;
std::vector<const char *> argvv = { std::vector<const char *> argvv = {
"clang-uml", "--config", "./test_config_data/simple.yml"}; "clang-uml", "--config", "./test_config_data/simple.yml"};
if (debug_log) argvv.push_back("-q");
argvv.push_back("-vvv");
else
argvv.push_back("-q");
clih.handle_options(argvv.size(), argvv.data()); clih.handle_options(argvv.size(), argvv.data());
return session.run(); int res = context.run();
if (context.shouldExit())
return res;
return res;
} }

View File

@@ -15,15 +15,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define CATCH_CONFIG_RUNNER #define DOCTEST_CONFIG_IMPLEMENT
#define CATCH_CONFIG_CONSOLE_WIDTH 512
#include "catch.h" #include "doctest/doctest.h"
#include "cli/cli_handler.h" #include "cli/cli_handler.h"
#include "config/config.h" #include "config/config.h"
#include "util/util.h" #include "util/util.h"
TEST_CASE("Test config simple", "[unit-test]") TEST_CASE("Test config simple")
{ {
using clanguml::common::model::access_t; using clanguml::common::model::access_t;
using clanguml::common::model::relationship_t; using clanguml::common::model::relationship_t;
@@ -102,7 +102,7 @@ TEST_CASE("Test config simple", "[unit-test]")
relationship_t::kAggregation); relationship_t::kAggregation);
} }
TEST_CASE("Test config inherited", "[unit-test]") TEST_CASE("Test config inherited")
{ {
auto cfg = clanguml::config::load("./test_config_data/inherited.yml"); auto cfg = clanguml::config::load("./test_config_data/inherited.yml");
@@ -132,7 +132,7 @@ TEST_CASE("Test config inherited", "[unit-test]")
CHECK(cus.puml().after.at(1) == "This is a common footnote"); CHECK(cus.puml().after.at(1) == "This is a common footnote");
} }
TEST_CASE("Test config includes", "[unit-test]") TEST_CASE("Test config includes")
{ {
auto cfg = clanguml::config::load("./test_config_data/includes.yml"); auto cfg = clanguml::config::load("./test_config_data/includes.yml");
@@ -156,7 +156,7 @@ TEST_CASE("Test config includes", "[unit-test]")
clanguml::config::method_arguments::none); clanguml::config::method_arguments::none);
} }
TEST_CASE("Test config layout", "[unit-test]") TEST_CASE("Test config layout")
{ {
using namespace std::string_literals; using namespace std::string_literals;
@@ -242,7 +242,7 @@ TEST_CASE("Test config layout", "[unit-test]")
clanguml::common::model::diagram_t::kPackage); clanguml::common::model::diagram_t::kPackage);
} }
TEST_CASE("Test config emitters", "[unit-test]") TEST_CASE("Test config emitters")
{ {
auto cfg = clanguml::config::load("./test_config_data/complete.yml"); auto cfg = clanguml::config::load("./test_config_data/complete.yml");
@@ -268,7 +268,7 @@ TEST_CASE("Test config emitters", "[unit-test]")
std::filesystem::remove(tmp_file); std::filesystem::remove(tmp_file);
} }
TEST_CASE("Test config diagram_templates", "[unit-test]") TEST_CASE("Test config diagram_templates")
{ {
auto cfg = auto cfg =
clanguml::config::load("./test_config_data/diagram_templates.yml"); clanguml::config::load("./test_config_data/diagram_templates.yml");
@@ -327,7 +327,7 @@ TEST_CASE("Test config diagram_templates", "[unit-test]")
clanguml::common::model::diagram_t::kSequence); clanguml::common::model::diagram_t::kSequence);
} }
TEST_CASE("Test config sequence inherited", "[unit-test]") TEST_CASE("Test config sequence inherited")
{ {
auto cfg = clanguml::config::load( auto cfg = clanguml::config::load(
"./test_config_data/sequence_inheritable_options.yml"); "./test_config_data/sequence_inheritable_options.yml");
@@ -344,7 +344,7 @@ TEST_CASE("Test config sequence inherited", "[unit-test]")
CHECK(def.generate_return_types() == false); CHECK(def.generate_return_types() == false);
} }
TEST_CASE("Test config relative paths handling", "[unit-test]") TEST_CASE("Test config relative paths handling")
{ {
auto cfg = clanguml::config::load("./test_config_data/relative_to.yml"); auto cfg = clanguml::config::load("./test_config_data/relative_to.yml");
@@ -378,7 +378,7 @@ TEST_CASE("Test config relative paths handling", "[unit-test]")
"{}/test_config_data", std::filesystem::current_path().string())); "{}/test_config_data", std::filesystem::current_path().string()));
} }
TEST_CASE("Test using_module relative to", "[unit-test]") TEST_CASE("Test using_module relative to")
{ {
auto cfg = clanguml::config::load("./test_config_data/using_module.yml"); auto cfg = clanguml::config::load("./test_config_data/using_module.yml");
@@ -403,7 +403,7 @@ TEST_CASE("Test using_module relative to", "[unit-test]")
std::string{"modA"}, std::string{"modB"}, std::string{"modC"}}); std::string{"modA"}, std::string{"modB"}, std::string{"modC"}});
} }
TEST_CASE("Test config full clang uml dump", "[unit-test]") TEST_CASE("Test config full clang uml dump")
{ {
auto cfg = auto cfg =
clanguml::config::load("./test_config_data/clang_uml_config.yml"); clanguml::config::load("./test_config_data/clang_uml_config.yml");
@@ -411,7 +411,7 @@ TEST_CASE("Test config full clang uml dump", "[unit-test]")
CHECK(cfg.diagrams.size() == 32); CHECK(cfg.diagrams.size() == 32);
} }
TEST_CASE("Test config type aliases", "[unit-test]") TEST_CASE("Test config type aliases")
{ {
auto cfg = clanguml::config::load("./test_config_data/type_aliases.yml"); auto cfg = clanguml::config::load("./test_config_data/type_aliases.yml");
@@ -447,30 +447,23 @@ TEST_CASE("Test config type aliases", "[unit-test]")
/// ///
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Catch::Session session; doctest::Context context;
using namespace Catch::clara;
bool debug_log{false}; context.applyCommandLine(argc, argv);
auto cli = session.cli() |
Opt(debug_log, "debug_log")["-u"]["--debug-log"]("Enable debug logs");
session.cli(cli);
int returnCode = session.applyCommandLine(argc, argv);
if (returnCode != 0)
return returnCode;
clanguml::cli::cli_handler clih; clanguml::cli::cli_handler clih;
std::vector<const char *> argvv = { std::vector<const char *> argvv = {
"clang-uml", "--config", "./test_config_data/simple.yml"}; "clang-uml", "--config", "./test_config_data/simple.yml"};
if (debug_log) argvv.push_back("-q");
argvv.push_back("-vvv");
else
argvv.push_back("-q");
clih.handle_options(argvv.size(), argvv.data()); clih.handle_options(argvv.size(), argvv.data());
return session.run(); int res = context.run();
if (context.shouldExit())
return res;
return res;
} }

View File

@@ -15,14 +15,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define CATCH_CONFIG_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "decorators/decorators.h" #include "decorators/decorators.h"
#include "catch.h"
#include "util/util.h" #include "util/util.h"
TEST_CASE("Test decorator parser on regular comment", "[unit-test]") #include "doctest/doctest.h"
TEST_CASE("Test decorator parser on regular comment")
{ {
std::string comment = R"( std::string comment = R"(
\brief This is a comment. \brief This is a comment.
@@ -42,7 +42,7 @@ TEST_CASE("Test decorator parser on regular comment", "[unit-test]")
CHECK(clanguml::util::trim(comment) == stripped); CHECK(clanguml::util::trim(comment) == stripped);
} }
TEST_CASE("Test decorator parser on note", "[unit-test]") TEST_CASE("Test decorator parser on note")
{ {
std::string comment = R"( std::string comment = R"(
\brief This is a comment. \brief This is a comment.
@@ -99,7 +99,7 @@ TEST_CASE("Test decorator parser on note", "[unit-test]")
\param b float a float)"); \param b float a float)");
} }
TEST_CASE("Test decorator parser on note with custom tag", "[unit-test]") TEST_CASE("Test decorator parser on note with custom tag")
{ {
std::string comment = R"( std::string comment = R"(
\brief This is a comment. \brief This is a comment.
@@ -156,7 +156,7 @@ TEST_CASE("Test decorator parser on note with custom tag", "[unit-test]")
\param b float a float)"); \param b float a float)");
} }
TEST_CASE("Test decorator parser on style", "[unit-test]") TEST_CASE("Test decorator parser on style")
{ {
std::string comment = R"( std::string comment = R"(
\uml{style[#green,dashed,thickness=4]} \uml{style[#green,dashed,thickness=4]}
@@ -175,7 +175,7 @@ TEST_CASE("Test decorator parser on style", "[unit-test]")
CHECK(stripped.empty()); CHECK(stripped.empty());
} }
TEST_CASE("Test decorator parser on aggregation", "[unit-test]") TEST_CASE("Test decorator parser on aggregation")
{ {
std::string comment = R"( std::string comment = R"(
\uml{aggregation[0..1:0..*]} \uml{aggregation[0..1:0..*]}
@@ -194,7 +194,7 @@ TEST_CASE("Test decorator parser on aggregation", "[unit-test]")
CHECK(stripped.empty()); CHECK(stripped.empty());
} }
TEST_CASE("Test decorator parser on skip", "[unit-test]") TEST_CASE("Test decorator parser on skip")
{ {
std::string comment = R"( std::string comment = R"(
\uml{skip} \uml{skip}
@@ -212,7 +212,7 @@ TEST_CASE("Test decorator parser on skip", "[unit-test]")
CHECK(stripped.empty()); CHECK(stripped.empty());
} }
TEST_CASE("Test decorator parser on skiprelationship", "[unit-test]") TEST_CASE("Test decorator parser on skiprelationship")
{ {
std::string comment = R"( std::string comment = R"(
\uml{skiprelationship} \uml{skiprelationship}
@@ -230,7 +230,7 @@ TEST_CASE("Test decorator parser on skiprelationship", "[unit-test]")
CHECK(stripped.empty()); CHECK(stripped.empty());
} }
TEST_CASE("Test decorator parser on diagram scope", "[unit-test]") TEST_CASE("Test decorator parser on diagram scope")
{ {
std::string comment = R"( std::string comment = R"(
\uml{note:diagram1, diagram2, \uml{note:diagram1, diagram2,
@@ -259,7 +259,7 @@ TEST_CASE("Test decorator parser on diagram scope", "[unit-test]")
CHECK(stripped.empty()); CHECK(stripped.empty());
} }
TEST_CASE("Test invalid comment - unterminated curly brace", "[unit-test]") TEST_CASE("Test invalid comment - unterminated curly brace")
{ {
std::string comment = R"( std::string comment = R"(
Test test test Test test test

View File

@@ -15,11 +15,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define DOCTEST_CONFIG_IMPLEMENT
#define CATCH_CONFIG_RUNNER #include "doctest/doctest.h"
#define CATCH_CONFIG_CONSOLE_WIDTH 512
#include "catch.h"
#include "class_diagram/model/class.h" #include "class_diagram/model/class.h"
#include "cli/cli_handler.h" #include "cli/cli_handler.h"
@@ -31,7 +29,7 @@
#include <filesystem> #include <filesystem>
TEST_CASE("Test diagram paths filter", "[unit-test]") TEST_CASE("Test diagram paths filter")
{ {
using clanguml::common::model::diagram_filter; using clanguml::common::model::diagram_filter;
using clanguml::common::model::source_file; using clanguml::common::model::source_file;
@@ -56,7 +54,7 @@ TEST_CASE("Test diagram paths filter", "[unit-test]")
make_path("sequence_diagram/visitor/translation_unit_visitor.h"))); make_path("sequence_diagram/visitor/translation_unit_visitor.h")));
} }
TEST_CASE("Test method_types include filter", "[unit-test]") TEST_CASE("Test method_types include filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::common::model::access_t; using clanguml::common::model::access_t;
@@ -81,7 +79,7 @@ TEST_CASE("Test method_types include filter", "[unit-test]")
CHECK(!filter.should_include(cm)); CHECK(!filter.should_include(cm));
} }
TEST_CASE("Test method_types exclude filter", "[unit-test]") TEST_CASE("Test method_types exclude filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::common::model::access_t; using clanguml::common::model::access_t;
@@ -109,7 +107,7 @@ TEST_CASE("Test method_types exclude filter", "[unit-test]")
CHECK(!filter.should_include(cm)); CHECK(!filter.should_include(cm));
} }
TEST_CASE("Test namespaces filter", "[unit-test]") TEST_CASE("Test namespaces filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::class_diagram::model::class_parent; using clanguml::class_diagram::model::class_parent;
@@ -173,7 +171,7 @@ TEST_CASE("Test namespaces filter", "[unit-test]")
CHECK(!filter.should_include(p)); CHECK(!filter.should_include(p));
} }
TEST_CASE("Test elements regexp filter", "[unit-test]") TEST_CASE("Test elements regexp filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::common::model::access_t; using clanguml::common::model::access_t;
@@ -213,7 +211,7 @@ TEST_CASE("Test elements regexp filter", "[unit-test]")
CHECK(filter.should_include(c)); CHECK(filter.should_include(c));
} }
TEST_CASE("Test namespaces regexp filter", "[unit-test]") TEST_CASE("Test namespaces regexp filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::class_diagram::model::class_parent; using clanguml::class_diagram::model::class_parent;
@@ -272,7 +270,7 @@ TEST_CASE("Test namespaces regexp filter", "[unit-test]")
CHECK(filter.should_include(p)); CHECK(filter.should_include(p));
} }
TEST_CASE("Test subclasses regexp filter", "[unit-test]") TEST_CASE("Test subclasses regexp filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::class_diagram::model::class_parent; using clanguml::class_diagram::model::class_parent;
@@ -362,7 +360,7 @@ TEST_CASE("Test subclasses regexp filter", "[unit-test]")
CHECK(!filter.should_include(*diagram.find<class_>("ns1::ns2::C1"))); CHECK(!filter.should_include(*diagram.find<class_>("ns1::ns2::C1")));
} }
TEST_CASE("Test parents regexp filter", "[unit-test]") TEST_CASE("Test parents regexp filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::class_diagram::model::class_parent; using clanguml::class_diagram::model::class_parent;
@@ -452,7 +450,7 @@ TEST_CASE("Test parents regexp filter", "[unit-test]")
CHECK(!filter.should_include(*diagram.find<class_>("ns1::ns2::Common"))); CHECK(!filter.should_include(*diagram.find<class_>("ns1::ns2::Common")));
} }
TEST_CASE("Test specializations regexp filter", "[unit-test]") TEST_CASE("Test specializations regexp filter")
{ {
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
using clanguml::class_diagram::model::class_parent; using clanguml::class_diagram::model::class_parent;
@@ -516,7 +514,7 @@ TEST_CASE("Test specializations regexp filter", "[unit-test]")
CHECK(!filter.should_include(*diagram.find<class_>("A<double>"))); CHECK(!filter.should_include(*diagram.find<class_>("A<double>")));
} }
TEST_CASE("Test context regexp filter", "[unit-test]") TEST_CASE("Test context regexp filter")
{ {
using clanguml::class_diagram::model::class_; using clanguml::class_diagram::model::class_;
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
@@ -605,7 +603,7 @@ TEST_CASE("Test context regexp filter", "[unit-test]")
CHECK(!filter.should_include(*diagram.find<class_>("C1"))); CHECK(!filter.should_include(*diagram.find<class_>("C1")));
} }
TEST_CASE("Test dependencies regexp filter", "[unit-test]") TEST_CASE("Test dependencies regexp filter")
{ {
using clanguml::class_diagram::model::class_; using clanguml::class_diagram::model::class_;
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
@@ -689,7 +687,7 @@ TEST_CASE("Test dependencies regexp filter", "[unit-test]")
CHECK(!filter.should_include(*diagram.find<class_>("C1"))); CHECK(!filter.should_include(*diagram.find<class_>("C1")));
} }
TEST_CASE("Test dependants regexp filter", "[unit-test]") TEST_CASE("Test dependants regexp filter")
{ {
using clanguml::class_diagram::model::class_; using clanguml::class_diagram::model::class_;
using clanguml::class_diagram::model::class_method; using clanguml::class_diagram::model::class_method;
@@ -773,7 +771,7 @@ TEST_CASE("Test dependants regexp filter", "[unit-test]")
CHECK(!filter.should_include(*diagram.find<class_>("C1"))); CHECK(!filter.should_include(*diagram.find<class_>("C1")));
} }
TEST_CASE("Test callee_types filter", "[unit-test]") TEST_CASE("Test callee_types filter")
{ {
using clanguml::common::to_id; using clanguml::common::to_id;
using clanguml::common::model::diagram_filter; using clanguml::common::model::diagram_filter;
@@ -829,30 +827,23 @@ TEST_CASE("Test callee_types filter", "[unit-test]")
/// ///
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Catch::Session session; doctest::Context context;
using namespace Catch::clara;
bool debug_log{false}; context.applyCommandLine(argc, argv);
auto cli = session.cli() |
Opt(debug_log, "debug_log")["-u"]["--debug-log"]("Enable debug logs");
session.cli(cli);
int returnCode = session.applyCommandLine(argc, argv);
if (returnCode != 0)
return returnCode;
clanguml::cli::cli_handler clih; clanguml::cli::cli_handler clih;
std::vector<const char *> argvv = { std::vector<const char *> argvv = {
"clang-uml", "--config", "./test_config_data/simple.yml"}; "clang-uml", "--config", "./test_config_data/simple.yml"};
if (debug_log) argvv.push_back("-q");
argvv.push_back("-vvv");
else
argvv.push_back("-q");
clih.handle_options(argvv.size(), argvv.data()); clih.handle_options(argvv.size(), argvv.data());
return session.run(); int res = context.run();
if (context.shouldExit())
return res;
return res;
} }

View File

@@ -15,16 +15,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define CATCH_CONFIG_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "catch.h" #include "doctest/doctest.h"
#include "class_diagram/model/class.h" #include "class_diagram/model/class.h"
#include "common/model/namespace.h" #include "common/model/namespace.h"
#include "common/model/package.h" #include "common/model/package.h"
#include "common/model/template_parameter.h" #include "common/model/template_parameter.h"
TEST_CASE("Test namespace_", "[unit-test]") TEST_CASE("Test namespace_")
{ {
using clanguml::common::model::namespace_; using clanguml::common::model::namespace_;
@@ -74,7 +74,7 @@ TEST_CASE("Test namespace_", "[unit-test]")
CHECK(ns8.relative(name) == "ccc<std::unique_ptr<ddd>>"); CHECK(ns8.relative(name) == "ccc<std::unique_ptr<ddd>>");
} }
TEST_CASE("Test class_::calculate_specialization_match", "[unit-test]") TEST_CASE("Test class_::calculate_specialization_match")
{ {
using clanguml::class_diagram::model::class_; using clanguml::class_diagram::model::class_;
using clanguml::common::model::template_parameter; using clanguml::common::model::template_parameter;
@@ -116,8 +116,7 @@ TEST_CASE("Test class_::calculate_specialization_match", "[unit-test]")
} }
} }
TEST_CASE( TEST_CASE("Test template_parameter::calculate_specialization_match")
"Test template_parameter::calculate_specialization_match", "[unit-test]")
{ {
using clanguml::common::model::template_parameter; using clanguml::common::model::template_parameter;
@@ -409,7 +408,7 @@ TEST_CASE(
} }
} }
TEST_CASE("Test common::model::package full_name", "[unit-test]") TEST_CASE("Test common::model::package full_name")
{ {
using clanguml::common::model::package; using clanguml::common::model::package;
using clanguml::common::model::path; using clanguml::common::model::path;

View File

@@ -15,13 +15,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define CATCH_CONFIG_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest/doctest.h"
#include "util/query_driver_output_extractor.h" #include "util/query_driver_output_extractor.h"
#include "catch.h" TEST_CASE("Test extract system include paths")
TEST_CASE("Test extract system include paths", "[unit-test]")
{ {
std::string output = R"(### std::string output = R"(###