mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 09:59:33 +08:00
Clang format
This commit is contained in:
@@ -47,8 +47,7 @@ set(SPDLOG_UTESTS_SOURCES
|
||||
test_circular_q.cpp
|
||||
test_ringbuffer_sink.cpp
|
||||
test_source_location.cpp
|
||||
test_log_level.cpp
|
||||
)
|
||||
test_log_level.cpp)
|
||||
|
||||
if(NOT SPDLOG_NO_EXCEPTIONS)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
||||
@@ -82,4 +81,3 @@ endfunction()
|
||||
if(SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_ALL)
|
||||
spdlog_prepare_test(spdlog-utests spdlog::spdlog)
|
||||
endif()
|
||||
|
||||
|
@@ -8,11 +8,10 @@ TEST_CASE("test_default_level", "[log_level]")
|
||||
auto test_sink = std::make_shared<spdlog::sinks::test_sink_st>();
|
||||
REQUIRE(test_sink->log_level() == spdlog::level::trace);
|
||||
spdlog::logger logger("test-level", test_sink);
|
||||
REQUIRE(test_sink->log_level() == spdlog::level::trace);\
|
||||
REQUIRE(test_sink->log_level() == spdlog::level::trace);
|
||||
REQUIRE(logger.log_level() == spdlog::level::info);
|
||||
}
|
||||
|
||||
|
||||
// test that logger log only messages with level bigger or equal to its level
|
||||
void test_logger_level(spdlog::level level);
|
||||
TEST_CASE("test_logger_levels", "[log_level]")
|
||||
@@ -24,7 +23,6 @@ TEST_CASE("test_logger_levels", "[log_level]")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// test that logger log all messages with level bigger or equal to its level
|
||||
void test_sink_level(spdlog::level level);
|
||||
TEST_CASE("test_sink_levels", "[log_level]")
|
||||
@@ -36,7 +34,6 @@ TEST_CASE("test_sink_levels", "[log_level]")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// test helpers to check that logger/sink displays only messages with level bigger or equal to its level
|
||||
//
|
||||
@@ -44,15 +41,11 @@ auto get_expected_messages(spdlog::level level)
|
||||
{
|
||||
// expected messages for each level
|
||||
static const std::map<spdlog::level, std::vector<std::string>> messages = {
|
||||
{spdlog::level::trace, {"trace hello", "debug hello", "info hello", "warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::debug, {"debug hello", "info hello", "warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::info, {"info hello", "warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::warn, {"warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::err, {"error hello", "critical hello"}},
|
||||
{spdlog::level::critical, {"critical hello"}},
|
||||
{spdlog::level::off, {}},
|
||||
{spdlog::level::n_levels, {}}
|
||||
};
|
||||
{spdlog::level::trace, {"trace hello", "debug hello", "info hello", "warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::debug, {"debug hello", "info hello", "warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::info, {"info hello", "warning hello", "error hello", "critical hello"}},
|
||||
{spdlog::level::warn, {"warning hello", "error hello", "critical hello"}}, {spdlog::level::err, {"error hello", "critical hello"}},
|
||||
{spdlog::level::critical, {"critical hello"}}, {spdlog::level::off, {}}, {spdlog::level::n_levels, {}}};
|
||||
return messages.at(level);
|
||||
}
|
||||
|
||||
@@ -73,10 +66,9 @@ void test_logger_level(spdlog::level level)
|
||||
logger.critical("hello");
|
||||
|
||||
auto lines = test_sink->lines();
|
||||
REQUIRE(lines == get_expected_messages(level));
|
||||
REQUIRE(lines == get_expected_messages(level));
|
||||
}
|
||||
|
||||
|
||||
// test that sink displays all messages with level bigger or equal to its level
|
||||
void test_sink_level(spdlog::level level)
|
||||
{
|
||||
@@ -98,5 +90,5 @@ void test_sink_level(spdlog::level level)
|
||||
logger.critical("hello");
|
||||
|
||||
auto lines = test_sink->lines();
|
||||
REQUIRE(lines == get_expected_messages(level));
|
||||
REQUIRE(lines == get_expected_messages(level));
|
||||
}
|
Reference in New Issue
Block a user