mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-12 17:00:25 +08:00
Fix unittests
This commit is contained in:
parent
c844ea4423
commit
b658ff2124
@ -257,13 +257,21 @@ TEST_CASE("clone-formatter-2", "[pattern_formatter]")
|
||||
//
|
||||
// Test source location formatting
|
||||
//
|
||||
/*
|
||||
|
||||
#ifdef _WIN32
|
||||
static const char *test_path = "\\a\\b\\myfile.cpp";
|
||||
#else
|
||||
static const char *test_path = "/a/b//myfile.cpp";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
TEST_CASE("short filename formatter-1", "[pattern_formatter]")
|
||||
{
|
||||
spdlog::pattern_formatter formatter("%s", spdlog::pattern_time_type::local, "");
|
||||
fmt::memory_buffer formatted;
|
||||
std::string logger_name = "logger-name";
|
||||
spdlog::source_loc source_loc{"/a/b/c/d/myfile.cpp", 123, "some_func()"};
|
||||
spdlog::source_loc source_loc{test_path , 123, "some_func()"};
|
||||
spdlog::details::log_msg msg(source_loc, "logger-name", spdlog::level::info, "Hello");
|
||||
formatter.format(msg, formatted);
|
||||
REQUIRE(fmt::to_string(formatted) == "myfile.cpp");
|
||||
@ -293,12 +301,12 @@ TEST_CASE("short filename formatter-3", "[pattern_formatter]")
|
||||
|
||||
TEST_CASE("full filename formatter", "[pattern_formatter]")
|
||||
{
|
||||
spdlog::pattern_formatter formatter("%g:%#", spdlog::pattern_time_type::local, "");
|
||||
spdlog::pattern_formatter formatter("%g", spdlog::pattern_time_type::local, "");
|
||||
fmt::memory_buffer formatted;
|
||||
std::string logger_name = "logger-name";
|
||||
spdlog::source_loc source_loc{"/a/b/c/d/myfile.cpp", 123, "some_func()"};
|
||||
spdlog::source_loc source_loc{test_path , 123, "some_func()"};
|
||||
spdlog::details::log_msg msg(source_loc, "logger-name", spdlog::level::info, "Hello");
|
||||
formatter.format(msg, formatted);
|
||||
REQUIRE(fmt::to_string(formatted) == "/a/b/c/d/myfile.cpp:123");
|
||||
REQUIRE(fmt::to_string(formatted) == test_path);
|
||||
}
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user