From f0a4ddd78be3cba6423552eb242cdcd1c9e4e3f2 Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Wed, 6 Jan 2021 20:00:59 -0500 Subject: [PATCH] Fix character issues in test_errors.cpp --- tests/test_errors.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_errors.cpp b/tests/test_errors.cpp index 10ee929c..b7673581 100644 --- a/tests/test_errors.cpp +++ b/tests/test_errors.cpp @@ -5,6 +5,9 @@ #include +#define SIMPLE_LOG "test_logs/simple_log.txt" +#define SIMPLE_ASYNC_LOG "test_logs/simple_async_log.txt" + class failing_sink : public spdlog::sinks::base_sink { protected: @@ -22,7 +25,7 @@ protected: TEST_CASE("default_error_handler", "[errors]]") { prepare_logdir(); - std::string filename = "test_logs/simple_log.txt"; + spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG); auto logger = spdlog::create("test-error", filename, true); logger->set_pattern("%v"); @@ -31,8 +34,8 @@ TEST_CASE("default_error_handler", "[errors]]") logger->flush(); using spdlog::details::os::default_eol; - REQUIRE(file_contents(filename) == fmt::format("Test message 2{}", default_eol)); - REQUIRE(count_lines(filename) == 1); + REQUIRE(file_contents(SIMPLE_LOG) == fmt::format("Test message 2{}", default_eol)); + REQUIRE(count_lines(SIMPLE_LOG) == 1); } struct custom_ex @@ -40,7 +43,7 @@ struct custom_ex TEST_CASE("custom_error_handler", "[errors]]") { prepare_logdir(); - std::string filename = "test_logs/simple_log.txt"; + spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG); auto logger = spdlog::create("logger", filename, true); logger->flush_on(spdlog::level::info); logger->set_error_handler([=](const std::string &) { throw custom_ex(); }); @@ -48,7 +51,7 @@ TEST_CASE("custom_error_handler", "[errors]]") REQUIRE_THROWS_AS(logger->info("Bad format msg {} {}", "xxx"), custom_ex); logger->info("Good message #2"); - require_message_count(filename, 2); + require_message_count(SIMPLE_LOG, 2); } TEST_CASE("default_error_handler2", "[errors]]") @@ -72,7 +75,7 @@ TEST_CASE("async_error_handler", "[errors]]") prepare_logdir(); std::string err_msg("log failed with some msg"); - std::string filename = "test_logs/simple_async_log.txt"; + spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_ASYNC_LOG); { spdlog::init_thread_pool(128, 1); auto logger = spdlog::create_async("logger", filename, true); @@ -90,7 +93,7 @@ TEST_CASE("async_error_handler", "[errors]]") spdlog::drop("logger"); // force logger to drain the queue and shutdown } spdlog::init_thread_pool(128, 1); - require_message_count(filename, 2); + require_message_count(SIMPLE_ASYNC_LOG, 2); REQUIRE(file_contents("test_logs/custom_err.txt") == err_msg); }