From 8dc7ba7e3dec45b1188d790bb1fa9b1e3a6ec199 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 29 Sep 2023 00:45:09 +0300 Subject: [PATCH] Cleaned tests --- include/spdlog/sinks/msvc_sink.h | 1 - tests/CMakeLists.txt | 2 +- tests/includes.h | 5 ----- tests/test_bin_to_hex.cpp | 1 + ..._daily_logger.cpp => test_daily_and_rotation_loggers.cpp} | 3 ++- tests/test_errors.cpp | 1 + tests/test_file_helper.cpp | 1 + tests/test_file_logging.cpp | 2 ++ tests/test_macros.cpp | 1 + tests/test_misc.cpp | 1 + tests/test_pattern_formatter.cpp | 1 + tests/test_registry.cpp | 2 ++ tests/test_source_location.cpp | 4 +++- 13 files changed, 16 insertions(+), 9 deletions(-) rename tests/{test_daily_logger.cpp => test_daily_and_rotation_loggers.cpp} (98%) diff --git a/include/spdlog/sinks/msvc_sink.h b/include/spdlog/sinks/msvc_sink.h index 62b59945..e941be3f 100644 --- a/include/spdlog/sinks/msvc_sink.h +++ b/include/spdlog/sinks/msvc_sink.h @@ -49,4 +49,3 @@ using windebug_sink_st = msvc_sink_st; } // namespace sinks } // namespace spdlog - diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7b8fc988..22971259 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,7 +26,7 @@ endif() set(SPDLOG_UTESTS_SOURCES test_file_helper.cpp test_file_logging.cpp - test_daily_logger.cpp + test_daily_and_rotation_loggers.cpp test_misc.cpp test_pattern_formatter.cpp test_async.cpp diff --git a/tests/includes.h b/tests/includes.h index 9b6d8454..d08001c1 100644 --- a/tests/includes.h +++ b/tests/includes.h @@ -28,11 +28,6 @@ #include "spdlog/async.h" #include "spdlog/details/fmt_helper.h" #include "spdlog/pattern_formatter.h" -#include "spdlog/sinks/basic_file_sink.h" -#include "spdlog/sinks/daily_file_sink.h" -#include "spdlog/sinks/msvc_sink.h" #include "spdlog/sinks/null_sink.h" -#include "spdlog/sinks/ostream_sink.h" -#include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" #include "spdlog/spdlog.h" diff --git a/tests/test_bin_to_hex.cpp b/tests/test_bin_to_hex.cpp index 7763a5c6..28f44151 100644 --- a/tests/test_bin_to_hex.cpp +++ b/tests/test_bin_to_hex.cpp @@ -1,5 +1,6 @@ #include "includes.h" #include "spdlog/fmt/bin_to_hex.h" +#include "spdlog/sinks/ostream_sink.h" #include "test_sink.h" TEST_CASE("to_hex", "[to_hex]") { diff --git a/tests/test_daily_logger.cpp b/tests/test_daily_and_rotation_loggers.cpp similarity index 98% rename from tests/test_daily_logger.cpp rename to tests/test_daily_and_rotation_loggers.cpp index fe4783cb..15336a6e 100644 --- a/tests/test_daily_logger.cpp +++ b/tests/test_daily_and_rotation_loggers.cpp @@ -3,6 +3,8 @@ * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE */ #include "includes.h" +#include "spdlog/sinks/daily_file_sink.h" +#include "spdlog/sinks/rotating_file_sink.h" #ifdef SPDLOG_USE_STD_FORMAT using filename_memory_buf_t = std::basic_string; @@ -73,7 +75,6 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]") { } logger->flush(); - require_message_count(filename_buf_to_utf8string(w), 10); } diff --git a/tests/test_errors.cpp b/tests/test_errors.cpp index 05e9e9f7..4729123b 100644 --- a/tests/test_errors.cpp +++ b/tests/test_errors.cpp @@ -5,6 +5,7 @@ #include #include "includes.h" +#include "spdlog/sinks/basic_file_sink.h" #define SIMPLE_LOG "test_logs/simple_log.txt" #define SIMPLE_ASYNC_LOG "test_logs/simple_async_log.txt" diff --git a/tests/test_file_helper.cpp b/tests/test_file_helper.cpp index de7d51d9..c3d73d0d 100644 --- a/tests/test_file_helper.cpp +++ b/tests/test_file_helper.cpp @@ -3,6 +3,7 @@ * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE */ #include "includes.h" +#include "spdlog/sinks/rotating_file_sink.h" #define TEST_FILENAME "test_logs/file_helper_test.txt" diff --git a/tests/test_file_logging.cpp b/tests/test_file_logging.cpp index ac378b5c..c0abd34e 100644 --- a/tests/test_file_logging.cpp +++ b/tests/test_file_logging.cpp @@ -3,6 +3,8 @@ * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE */ #include "includes.h" +#include "spdlog/sinks/basic_file_sink.h" +#include "spdlog/sinks/rotating_file_sink.h" #define SIMPLE_LOG "test_logs/simple_log" #define ROTATING_LOG "test_logs/rotating_log" diff --git a/tests/test_macros.cpp b/tests/test_macros.cpp index 132706f1..4ab49576 100644 --- a/tests/test_macros.cpp +++ b/tests/test_macros.cpp @@ -4,6 +4,7 @@ */ #include "includes.h" +#include "spdlog/sinks/basic_file_sink.h" #if SPDLOG_ACTIVE_LEVEL != SPDLOG_LEVEL_DEBUG #error "Invalid SPDLOG_ACTIVE_LEVEL in test. Should be SPDLOG_LEVEL_DEBUG" diff --git a/tests/test_misc.cpp b/tests/test_misc.cpp index 85dda851..a3da6775 100644 --- a/tests/test_misc.cpp +++ b/tests/test_misc.cpp @@ -1,4 +1,5 @@ #include "includes.h" +#include "spdlog/sinks/ostream_sink.h" #include "test_sink.h" template diff --git a/tests/test_pattern_formatter.cpp b/tests/test_pattern_formatter.cpp index 2db9a33f..d7cdfce2 100644 --- a/tests/test_pattern_formatter.cpp +++ b/tests/test_pattern_formatter.cpp @@ -1,4 +1,5 @@ #include "includes.h" +#include "spdlog/sinks/ostream_sink.h" #include "test_sink.h" using spdlog::memory_buf_t; diff --git a/tests/test_registry.cpp b/tests/test_registry.cpp index 317c69da..d223761e 100644 --- a/tests/test_registry.cpp +++ b/tests/test_registry.cpp @@ -1,4 +1,6 @@ #include "includes.h" +#include "spdlog/sinks/daily_file_sink.h" +#include "spdlog/sinks/rotating_file_sink.h" static const char *const tested_logger_name = "null_logger"; static const char *const tested_logger_name2 = "null_logger2"; diff --git a/tests/test_source_location.cpp b/tests/test_source_location.cpp index d810d340..6573606f 100644 --- a/tests/test_source_location.cpp +++ b/tests/test_source_location.cpp @@ -1,5 +1,6 @@ #define SPDLOG_SOURCE_LOCATION #include "includes.h" +#include "spdlog/sinks/ostream_sink.h" #include "test_sink.h" #if defined(SPDLOG_HAVE_STD_SOURCE_LOCATION) || defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION) @@ -11,9 +12,10 @@ TEST_CASE("test_source_location", "[source_location]") { auto oss_sink = std::make_shared(oss); spdlog::logger oss_logger("oss", oss_sink); oss_logger.set_pattern("%s:%# %v"); + oss_logger.info("Hello {}", "source location"); REQUIRE(oss.str() == - std::string("test_source_location.cpp:14 Hello source location") + default_eol); + std::string("test_source_location.cpp:16 Hello source location") + default_eol); } #endif