diff --git a/src/include/embetech/logger.h b/src/include/embetech/logger.h index 84e6b30..55eb809 100644 --- a/src/include/embetech/logger.h +++ b/src/include/embetech/logger.h @@ -532,7 +532,7 @@ typedef struct { # ifdef __cplusplus # define LOGGER_HEADER_DESCR(lvl) (LOGGER_HeaderDescriptor{.level = lvl, .channel = LOGGER_HEADER "", .file = LOGGER_FILE "", .line = __LINE__}) # else -# define LOGGER_HEADER_DESCR(lvl) (LOGGER_HeaderDescriptor){.level = lvl, .channel = LOGGER_HEADER "", .file = LOGGER_FILE "", .line = __LINE__}) +# define LOGGER_HEADER_DESCR(lvl) ((LOGGER_HeaderDescriptor){.level = lvl, .channel = LOGGER_HEADER "", .file = LOGGER_FILE "", .line = __LINE__}) # endif #else diff --git a/tests/ut05_location/CMakeLists.txt b/tests/ut05_location/CMakeLists.txt index eab40b0..19ab547 100644 --- a/tests/ut05_location/CMakeLists.txt +++ b/tests/ut05_location/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(logger_test_proxy5_1 ${LOGGER_SOURCES}) target_include_directories(logger_test_proxy5_1 PUBLIC ${LOGGER_INCLUDES}) target_compile_definitions(logger_test_proxy5_1 PUBLIC LOGGER_HEADER_WITH_LOCATION=1 LOGGER_FILE="OVERRIDEN") -add_executable(logger_ut05_1 ut05_1_location.cpp) +add_executable(logger_ut05_1 ut05_1_location.cpp ut05_1_location.c) target_link_libraries(logger_ut05_1 PRIVATE logger_test_proxy5_1 logger_test_common) add_library(logger_test_proxy5_2 ${LOGGER_SOURCES}) @@ -35,6 +35,7 @@ add_dependencies(logger_ut logger_ut05_1) add_dependencies(logger_ut logger_ut05_2) add_dependencies(logger_ut logger_ut05_3) + gtest_discover_tests(logger_ut05_1) gtest_discover_tests(logger_ut05_2) gtest_discover_tests(logger_ut05_3) diff --git a/tests/ut05_location/ut05_1_location.c b/tests/ut05_location/ut05_1_location.c new file mode 100644 index 0000000..c3f3ec5 --- /dev/null +++ b/tests/ut05_location/ut05_1_location.c @@ -0,0 +1,7 @@ +#include + + +void log_test_message(void) { + #line 1 + LOGGER_NOTICE("test message"); +} \ No newline at end of file diff --git a/tests/ut05_location/ut05_1_location.cpp b/tests/ut05_location/ut05_1_location.cpp index d542b4e..2fadba9 100644 --- a/tests/ut05_location/ut05_1_location.cpp +++ b/tests/ut05_location/ut05_1_location.cpp @@ -1,9 +1,12 @@ -#include #include +#include #include +extern "C" void log_test_message(void); // defined in ut05_1_location.c + + TEST(LOGGER, UT05_CodeLocation) { std::stringstream received; auto clear_output = [&received]() { @@ -17,9 +20,15 @@ TEST(LOGGER, UT05_CodeLocation) { char const* const msg = "test message"; { + char const* const expected = "DEFAULT (N) [OVERRIDEN:1]: test message\n"; + #line 1 - char const* const expected = "DEFAULT (N) [OVERRIDEN:2]: test message\n"; LOGGER_NOTICE(msg); + + EXPECT_EQ(expected, received.str()); + clear_output(); + + log_test_message(); EXPECT_EQ(expected, received.str()); clear_output(); } @@ -31,5 +40,9 @@ TEST(LOGGER, UT05_CodeLocation) { LOGGER_WARNING(msg); EXPECT_EQ(expected, received.str()); clear_output(); + + log_test_message(); + EXPECT_EQ(expected, received.str()); + clear_output(); } } \ No newline at end of file