Add unit test for daily_filename_format_calculator
This commit is contained in:
parent
a6945d046f
commit
ba120e524b
@ -75,7 +75,7 @@ struct daily_filename_format_calculator
|
|||||||
return buf;
|
return buf;
|
||||||
#else
|
#else
|
||||||
fmt::basic_memory_buffer<filename_t::value_type> tm_format;
|
fmt::basic_memory_buffer<filename_t::value_type> tm_format;
|
||||||
tm_format.append(specs.begin(), specs.end());
|
tm_format.append(filename.c_str(), filename.c_str() + filename.size());
|
||||||
// By appending an extra space we can distinguish an empty result that
|
// By appending an extra space we can distinguish an empty result that
|
||||||
// indicates insufficient buffer size from a guaranteed non-empty result
|
// indicates insufficient buffer size from a guaranteed non-empty result
|
||||||
// https://github.com/fmtlib/fmt/issues/2238
|
// https://github.com/fmtlib/fmt/issues/2238
|
||||||
|
@ -142,6 +142,16 @@ TEST_CASE("daily_file_sink::daily_filename_calculator", "[daily_file_sink]]")
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TEST_CASE("daily_file_sink::daily_filename_format_calculator", "[daily_file_sink]]")
|
||||||
|
{
|
||||||
|
std::tm tm = spdlog::details::os::localtime();
|
||||||
|
// example-YYYY-MM-DD.log
|
||||||
|
auto filename =
|
||||||
|
spdlog::sinks::daily_filename_format_calculator::calc_filename(SPDLOG_FILENAME_T("example-%Y-%m-%d.log"), tm);
|
||||||
|
|
||||||
|
REQUIRE(filename == spdlog::fmt_lib::format(SPDLOG_FILENAME_T("example-{:04d}-{:02d}-{:02d}.log"), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday));
|
||||||
|
}
|
||||||
|
|
||||||
/* Test removal of old files */
|
/* Test removal of old files */
|
||||||
static spdlog::details::log_msg create_msg(std::chrono::seconds offset)
|
static spdlog::details::log_msg create_msg(std::chrono::seconds offset)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user