diff --git a/src/config/config.h b/src/config/config.h index d235eede..29b01740 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -261,7 +261,7 @@ template <> struct convert { rhs.diagrams[name] = std::make_shared( d.second.as()); } - if (diagram_type == "sequence") { + else if (diagram_type == "sequence") { rhs.diagrams[name] = std::make_shared( d.second.as()); } diff --git a/src/puml/sequence_diagram_generator.h b/src/puml/sequence_diagram_generator.h index 29950fea..2e7c233f 100644 --- a/src/puml/sequence_diagram_generator.h +++ b/src/puml/sequence_diagram_generator.h @@ -164,7 +164,7 @@ clanguml::model::sequence_diagram::diagram generate( auto cursor = clang_getTranslationUnitCursor(tu); if (clang_Cursor_isNull(cursor)) { - spdlog::debug("CURSOR IS NULL"); + spdlog::debug("Cursor is NULL"); } spdlog::debug("Cursor kind: {}", diff --git a/src/uml/class_diagram_visitor.h b/src/uml/class_diagram_visitor.h index 03f5d146..7b1e2be3 100644 --- a/src/uml/class_diagram_visitor.h +++ b/src/uml/class_diagram_visitor.h @@ -178,14 +178,14 @@ static enum CXChildVisitResult enum_visitor( cx::cursor cursor{std::move(cx_cursor)}; cx::cursor parent{std::move(cx_parent)}; - spdlog::info("Visiting enum {}: {} - {}:{}", ctx->element.name, + spdlog::debug("Visiting enum {}: {} - {}:{}", ctx->element.name, cursor.spelling(), cursor.kind()); enum CXChildVisitResult ret = CXChildVisit_Break; switch (cursor.kind()) { case CXCursor_EnumConstantDecl: visit_if_cursor_valid(cursor, [ctx](cx::cursor cursor) { - spdlog::info("Adding enum constant {}::{}", ctx->element.name, + spdlog::debug("Adding enum constant {}::{}", ctx->element.name, cursor.spelling()); ctx->element.constants.emplace_back(cursor.spelling()); @@ -209,7 +209,7 @@ static enum CXChildVisitResult friend_class_visitor( cx::cursor cursor{std::move(cx_cursor)}; cx::cursor parent{std::move(cx_parent)}; - spdlog::info("Visiting friend class declaration {}: {} - {}:{}", + spdlog::debug("Visiting friend class declaration {}: {} - {}:{}", ctx->element.name, cursor.spelling(), cursor.kind(), cursor.referenced()); @@ -218,7 +218,7 @@ static enum CXChildVisitResult friend_class_visitor( case CXCursor_TemplateRef: case CXCursor_ClassTemplate: case CXCursor_TypeRef: { - spdlog::info("Analyzing friend declaration: {}, {}", cursor, + spdlog::debug("Analyzing friend declaration: {}, {}", cursor, cursor.specialized_cursor_template()); if (!ctx->ctx->config.should_include( @@ -254,7 +254,7 @@ static enum CXChildVisitResult class_visitor( std::string cursor_name_str = cursor.spelling(); - spdlog::info("Visiting {}: {} - {}", + spdlog::debug("Visiting {}: {} - {}", ctx->element.is_struct ? "struct" : "class", ctx->element.name, cursor); auto &config = ctx->ctx->config; @@ -280,7 +280,7 @@ static enum CXChildVisitResult class_visitor( c.name = cursor.fully_qualified(); c.namespace_ = ctx->ctx->namespace_; - spdlog::info("Class {} has {} template arguments.", c.name, + spdlog::debug("Class {} has {} template arguments.", c.name, cursor.template_argument_count()); auto class_ctx = @@ -294,7 +294,7 @@ static enum CXChildVisitResult class_visitor( containment.destination = c.name; ctx->element.relationships.emplace_back(std::move(containment)); - spdlog::info( + spdlog::debug( "Added relationship {} +-- {}", ctx->element.name, c.name); ctx->ctx->d.classes.emplace_back(std::move(c)); @@ -322,7 +322,7 @@ static enum CXChildVisitResult class_visitor( containment.destination = e.name; ctx->element.relationships.emplace_back(std::move(containment)); - spdlog::info( + spdlog::debug( "Added relationship {} +-- {}", ctx->element.name, e.name); ctx->ctx->d.enums.emplace_back(std::move(e)); @@ -330,8 +330,9 @@ static enum CXChildVisitResult class_visitor( ret = CXChildVisit_Continue; break; case CXCursor_TemplateTypeParameter: { - spdlog::info("Found template type parameter: {}: {}, isvariadic={}", - cursor, cursor.type(), cursor.is_template_parameter_variadic()); + spdlog::debug( + "Found template type parameter: {}: {}, isvariadic={}", cursor, + cursor.type(), cursor.is_template_parameter_variadic()); class_template ct; ct.type = ""; @@ -345,7 +346,7 @@ static enum CXChildVisitResult class_visitor( ret = CXChildVisit_Continue; } break; case CXCursor_NonTypeTemplateParameter: { - spdlog::info( + spdlog::debug( "Found template nontype parameter: {}: {}, isvariadic={}", cursor.spelling(), cursor.type(), cursor.is_template_parameter_variadic()); @@ -362,7 +363,7 @@ static enum CXChildVisitResult class_visitor( ret = CXChildVisit_Continue; } break; case CXCursor_TemplateTemplateParameter: { - spdlog::info("Found template template parameter: {}: {}", + spdlog::debug("Found template template parameter: {}: {}", cursor.spelling(), cursor.type()); class_template ct; @@ -394,7 +395,7 @@ static enum CXChildVisitResult class_visitor( m.scope = cx_access_specifier_to_scope(cursor.cxxaccess_specifier()); - spdlog::info("Adding method {} {}::{}()", m.type, + spdlog::debug("Adding method {} {}::{}()", m.type, ctx->element.name, cursor.spelling()); ctx->element.methods.emplace_back(std::move(m)); @@ -422,7 +423,7 @@ static enum CXChildVisitResult class_visitor( cursor.cxxaccess_specifier()); m.is_static = cursor.is_static(); - spdlog::info("Adding member {} {}::{} {}, {}, {}", m.type, + spdlog::debug("Adding member {} {}::{} {}, {}, {}", m.type, ctx->element.name, cursor.spelling(), t, tr, tr.type_declaration()); @@ -443,7 +444,7 @@ static enum CXChildVisitResult class_visitor( template_type = tr.type_declaration(); } - spdlog::info( + spdlog::debug( "Found template instantiation: {} ..|> {}", tr, template_type); @@ -472,7 +473,7 @@ static enum CXChildVisitResult class_visitor( ct.type = template_param; tinst.templates.emplace_back(std::move(ct)); - spdlog::info("Adding template argument '{}'", + spdlog::debug("Adding template argument '{}'", template_param); } @@ -519,7 +520,7 @@ static enum CXChildVisitResult class_visitor( // relationship type Skip: // - POD // - function variables - spdlog::info( + spdlog::debug( "Analyzing possible relationship candidate: {}", t.canonical().unqualified()); @@ -544,7 +545,7 @@ static enum CXChildVisitResult class_visitor( ctx->element.relationships.emplace_back( std::move(r)); - spdlog::info("Added relationship to: {}", + spdlog::debug("Added relationship to: {}", r.destination); } } @@ -557,7 +558,7 @@ static enum CXChildVisitResult class_visitor( break; } case CXCursor_ClassTemplatePartialSpecialization: { - spdlog::info("Found template specialization: {}", cursor); + spdlog::debug("Found template specialization: {}", cursor); ret = CXChildVisit_Continue; } break; case CXCursor_CXXBaseSpecifier: { @@ -571,7 +572,7 @@ static enum CXChildVisitResult class_visitor( auto base_access = cursor.cxxaccess_specifier(); - spdlog::info( + spdlog::debug( "Found base specifier: {} - {}", cursor_name_str, display_name); class_parent cp; @@ -636,7 +637,7 @@ static enum CXChildVisitResult translation_unit_visitor( case CXCursor_ClassTemplate: [[fallthrough]]; case CXCursor_ClassDecl: { - spdlog::info( + spdlog::debug( "Found class or class template declaration: {}", cursor); if (!ctx->config.should_include(cursor.fully_qualified())) { ret = CXChildVisit_Continue; diff --git a/src/uml/sequence_diagram_model.h b/src/uml/sequence_diagram_model.h index 89aa9985..504e3778 100644 --- a/src/uml/sequence_diagram_model.h +++ b/src/uml/sequence_diagram_model.h @@ -53,21 +53,9 @@ struct diagram { bool started{false}; std::string name; - // std::map sequences; std::map sequences; - void sort() - { - /* - std::sort(sequence.begin(), sequence.end(), - [](const auto &a, const auto &b) -> bool { - if (a.from_usr == b.from_usr) - return a.line > b.line; - - return a.from_usr > b.from_usr; - }); - */ - } + void sort() {} }; } } diff --git a/tests/t00002/test_case.h b/tests/t00002/test_case.h index bba481e9..8a100e3c 100644 --- a/tests/t00002/test_case.h +++ b/tests/t00002/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00002", "[unit-test]") +TEST_CASE("t00002", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00002"); auto diagram = config.diagrams["t00002_class"]; diff --git a/tests/t00003/test_case.h b/tests/t00003/test_case.h index c98052c8..fbbc0756 100644 --- a/tests/t00003/test_case.h +++ b/tests/t00003/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00003", "[unit-test]") +TEST_CASE("t00003", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00003"); auto diagram = config.diagrams["t00003_class"]; diff --git a/tests/t00004/test_case.h b/tests/t00004/test_case.h index 475a62ee..4c425ebf 100644 --- a/tests/t00004/test_case.h +++ b/tests/t00004/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00004", "[unit-test]") +TEST_CASE("t00004", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00004"); auto diagram = config.diagrams["t00004_class"]; diff --git a/tests/t00005/test_case.h b/tests/t00005/test_case.h index ca705666..8fdc8310 100644 --- a/tests/t00005/test_case.h +++ b/tests/t00005/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00005", "[unit-test]") +TEST_CASE("t00005", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00005"); auto diagram = config.diagrams["t00005_class"]; diff --git a/tests/t00006/test_case.h b/tests/t00006/test_case.h index a4a25a4e..8a1e39e8 100644 --- a/tests/t00006/test_case.h +++ b/tests/t00006/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00006", "[unit-test]") +TEST_CASE("t00006", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00006"); auto diagram = config.diagrams["t00006_class"]; diff --git a/tests/t00007/test_case.h b/tests/t00007/test_case.h index 46fe8b2e..9759728c 100644 --- a/tests/t00007/test_case.h +++ b/tests/t00007/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00007", "[unit-test]") +TEST_CASE("t00007", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00007"); auto diagram = config.diagrams["t00007_class"]; diff --git a/tests/t00008/test_case.h b/tests/t00008/test_case.h index da16be04..9d4635dd 100644 --- a/tests/t00008/test_case.h +++ b/tests/t00008/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00008", "[unit-test]") +TEST_CASE("t00008", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00008"); auto diagram = config.diagrams["t00008_class"]; diff --git a/tests/t00009/test_case.h b/tests/t00009/test_case.h index aad54071..43bf8b5a 100644 --- a/tests/t00009/test_case.h +++ b/tests/t00009/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00009", "[unit-test]") +TEST_CASE("t00009", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00009"); auto diagram = config.diagrams["t00009_class"]; diff --git a/tests/t00010/test_case.h b/tests/t00010/test_case.h index 20fffd5c..546d1dc9 100644 --- a/tests/t00010/test_case.h +++ b/tests/t00010/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00010", "[unit-test]") +TEST_CASE("t00010", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00010"); auto diagram = config.diagrams["t00010_class"]; diff --git a/tests/t00011/test_case.h b/tests/t00011/test_case.h index 04ab3e08..9295c488 100644 --- a/tests/t00011/test_case.h +++ b/tests/t00011/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00011", "[unit-test]") +TEST_CASE("t00011", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00011"); auto diagram = config.diagrams["t00011_class"]; diff --git a/tests/t00012/test_case.h b/tests/t00012/test_case.h index ddd0756b..cf098c9e 100644 --- a/tests/t00012/test_case.h +++ b/tests/t00012/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t00012", "[unit-test]") +TEST_CASE("t00012", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t00012"); auto diagram = config.diagrams["t00012_class"]; diff --git a/tests/t20001/test_case.h b/tests/t20001/test_case.h index 84ddb69d..65fe981c 100644 --- a/tests/t20001/test_case.h +++ b/tests/t20001/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t20001", "[unit-test]") +TEST_CASE("t20001", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t20001"); auto diagram = config.diagrams["t20001_sequence"]; diff --git a/tests/t90000/test_case.h b/tests/t90000/test_case.h index 9f0f2b40..48386a20 100644 --- a/tests/t90000/test_case.h +++ b/tests/t90000/test_case.h @@ -16,10 +16,8 @@ * limitations under the License. */ -TEST_CASE("Test t90000", "[unit-test]") +TEST_CASE("t90000", "[unit-test]") { - spdlog::set_level(spdlog::level::debug); - auto [config, db] = load_config("t90000"); auto diagram = config.diagrams["t90000_class"]; diff --git a/tests/test_cases.cc b/tests/test_cases.cc index 9c8b770a..b8dae9ab 100644 --- a/tests/test_cases.cc +++ b/tests/test_cases.cc @@ -15,10 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#define CATCH_CONFIG_MAIN +//#define CATCH_CONFIG_MAIN #include "test_cases.h" +#include + std::pair load_config( const std::string &test_name) { @@ -137,3 +139,15 @@ using clanguml::test::matchers::Static; // Other tests (e.g. configuration file) // #include "t90000/test_case.h" + +// +// Main test function +// +int main(int argc, char *argv[]) +{ + spdlog::default_logger_raw()->set_level(spdlog::level::debug); + + int result = Catch::Session().run(argc, argv); + + return result; +} diff --git a/tests/test_cases.h b/tests/test_cases.h index 750dfb4b..45b17aec 100644 --- a/tests/test_cases.h +++ b/tests/test_cases.h @@ -17,6 +17,8 @@ */ #pragma once +#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG + #include "config/config.h" #include "cx/compilation_database.h" #include "puml/class_diagram_generator.h" @@ -26,6 +28,8 @@ #include "uml/sequence_diagram_visitor.h" #include "util/util.h" +#define CATCH_CONFIG_RUNNER + #include "catch.h" #include