mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
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;
|
||||
#else
|
||||
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
|
||||
// indicates insufficient buffer size from a guaranteed non-empty result
|
||||
// https://github.com/fmtlib/fmt/issues/2238
|
||||
|
@ -142,6 +142,16 @@ TEST_CASE("daily_file_sink::daily_filename_calculator", "[daily_file_sink]]")
|
||||
}
|
||||
#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 */
|
||||
static spdlog::details::log_msg create_msg(std::chrono::seconds offset)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user