mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-12 22:20:05 +00:00
Workarounds for implementation-defined std::strftime behavior
This commit is contained in:
parent
85b38190d1
commit
509eac9575
@ -57,6 +57,10 @@ TEST(chrono_test, format_tm) {
|
|||||||
EXPECT_EQ(fmt::format("{:%T}", tm), "11:22:33");
|
EXPECT_EQ(fmt::format("{:%T}", tm), "11:22:33");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MSVC:
|
||||||
|
// minkernel\crts\ucrt\src\appcrt\time\wcsftime.cpp(971) : Assertion failed:
|
||||||
|
// timeptr->tm_year >= -1900 && timeptr->tm_year <= 8099
|
||||||
|
#ifndef _WIN32
|
||||||
TEST(chrono_test, format_tm_future) {
|
TEST(chrono_test, format_tm_future) {
|
||||||
auto tm = std::tm();
|
auto tm = std::tm();
|
||||||
tm.tm_year = 10445; // 10000+ years
|
tm.tm_year = 10445; // 10000+ years
|
||||||
@ -84,10 +88,15 @@ TEST(chrono_test, format_tm_past) {
|
|||||||
EXPECT_EQ(fmt::format("The date is {:%Y-%m-%d %H:%M:%S}.", tm),
|
EXPECT_EQ(fmt::format("The date is {:%Y-%m-%d %H:%M:%S}.", tm),
|
||||||
"The date is -101-04-25 11:22:33.");
|
"The date is -101-04-25 11:22:33.");
|
||||||
EXPECT_EQ(fmt::format("{:%Y}", tm), "-101");
|
EXPECT_EQ(fmt::format("{:%Y}", tm), "-101");
|
||||||
EXPECT_EQ(fmt::format("{:%D}", tm), "04/25/01");
|
|
||||||
|
// macOS %D - "04/25/01" (%y)
|
||||||
|
// Linux %D - "04/25/99" (%y)
|
||||||
|
// EXPECT_EQ(fmt::format("{:%D}", tm), "04/25/01");
|
||||||
|
|
||||||
EXPECT_EQ(fmt::format("{:%F}", tm), "-101-04-25");
|
EXPECT_EQ(fmt::format("{:%F}", tm), "-101-04-25");
|
||||||
EXPECT_EQ(fmt::format("{:%T}", tm), "11:22:33");
|
EXPECT_EQ(fmt::format("{:%T}", tm), "11:22:33");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(chrono_test, grow_buffer) {
|
TEST(chrono_test, grow_buffer) {
|
||||||
auto s = std::string("{:");
|
auto s = std::string("{:");
|
||||||
|
Loading…
Reference in New Issue
Block a user