Fixed test_macros tests

This commit is contained in:
Gabi Melman 2021-12-06 13:37:32 +02:00 committed by gabime
parent 8dd012096a
commit 1f58535920

View File

@ -28,6 +28,7 @@ TEST_CASE("debug and trace w/o format string", "[macros]]")
REQUIRE(ends_with(file_contents(TEST_FILENAME), spdlog::fmt_lib::format("Test message 2{}", default_eol))); REQUIRE(ends_with(file_contents(TEST_FILENAME), spdlog::fmt_lib::format("Test message 2{}", default_eol)));
REQUIRE(count_lines(TEST_FILENAME) == 1); REQUIRE(count_lines(TEST_FILENAME) == 1);
auto orig_default_logger = spdlog::default_logger();
spdlog::set_default_logger(logger); spdlog::set_default_logger(logger);
SPDLOG_TRACE("Test message 3"); SPDLOG_TRACE("Test message 3");
@ -36,6 +37,7 @@ TEST_CASE("debug and trace w/o format string", "[macros]]")
require_message_count(TEST_FILENAME, 2); require_message_count(TEST_FILENAME, 2);
REQUIRE(ends_with(file_contents(TEST_FILENAME), spdlog::fmt_lib::format("Test message 4{}", default_eol))); REQUIRE(ends_with(file_contents(TEST_FILENAME), spdlog::fmt_lib::format("Test message 4{}", default_eol)));
spdlog::set_default_logger(std::move(orig_default_logger));
} }
TEST_CASE("disable param evaluation", "[macros]") TEST_CASE("disable param evaluation", "[macros]")
@ -51,12 +53,3 @@ TEST_CASE("pass logger pointer", "[macros]")
SPDLOG_LOGGER_DEBUG(&ref, "Test message 2"); SPDLOG_LOGGER_DEBUG(&ref, "Test message 2");
} }
// ensure that even if right macro level is on- don't evaluate if the logger's level is not high enough
// TEST_CASE("disable param evaluation2", "[macros]")
//{
// auto logger = std::make_shared<spdlog::logger>("test-macro");
// logger->set_level(spdlog::level::off);
// int x = 0;
// SPDLOG_LOGGER_DEBUG(logger, "Test message {}", ++x);
// REQUIRE(x == 0);
//}