diff --git a/tests/test_pattern_formatter.cpp b/tests/test_pattern_formatter.cpp index 11a77ac2..24561ddb 100644 --- a/tests/test_pattern_formatter.cpp +++ b/tests/test_pattern_formatter.cpp @@ -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); } -*/ +