mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 02:21:34 +08:00
Added test of pattern_formatter::clone()
This commit is contained in:
parent
da84893921
commit
cc7e122915
@ -230,7 +230,7 @@ TEST_CASE("clone-default-formatter2", "[pattern_formatter]")
|
||||
|
||||
TEST_CASE("clone-formatter", "[pattern_formatter]")
|
||||
{
|
||||
auto formatter_1 = std::make_shared<spdlog::pattern_formatter>("%D %X [%] %v [%n] %v");
|
||||
auto formatter_1 = std::make_shared<spdlog::pattern_formatter>("%D %X [%] [%n] %v");
|
||||
auto formatter_2 = formatter_1->clone();
|
||||
std::string logger_name = "test";
|
||||
spdlog::details::log_msg msg(&logger_name, spdlog::level::info, "some message");
|
||||
@ -241,3 +241,21 @@ TEST_CASE("clone-formatter", "[pattern_formatter]")
|
||||
formatter_2->format(msg, formatted_2);
|
||||
REQUIRE(fmt::to_string(formatted_1) == fmt::to_string(formatted_2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TEST_CASE("clone-formatter-2", "[pattern_formatter]")
|
||||
{
|
||||
using spdlog::pattern_time_type;
|
||||
auto formatter_1 = std::make_shared<spdlog::pattern_formatter>("%D %X [%] [%n] %v", pattern_time_type::utc, "xxxxxx\n");
|
||||
auto formatter_2 = formatter_1->clone();
|
||||
std::string logger_name = "test2";
|
||||
spdlog::details::log_msg msg(&logger_name, spdlog::level::info, "some message");
|
||||
|
||||
fmt::memory_buffer formatted_1;
|
||||
fmt::memory_buffer formatted_2;
|
||||
formatter_1->format(msg, formatted_1);
|
||||
formatter_2->format(msg, formatted_2);
|
||||
REQUIRE(fmt::to_string(formatted_1) == fmt::to_string(formatted_2));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user