Implemented fmt::day, fmt::month, fmt::year and related unit tests (#3906)

This commit is contained in:
zivshek
2024-03-27 20:10:30 -04:00
committed by GitHub
parent 88620e53a4
commit 74a187288b
2 changed files with 114 additions and 5 deletions

View File

@@ -1011,4 +1011,16 @@ TEST(chrono_test, glibc_extensions) {
TEST(chrono_test, out_of_range) {
auto d = std::chrono::duration<unsigned long, std::giga>(538976288);
EXPECT_THROW((void)fmt::format("{:%j}", d), fmt::format_error);
}
}
TEST(chrono_test, year_month_day) {
auto loc = get_locale("es_ES.UTF-8");
std::locale::global(loc);
auto year = fmt::year(2024);
auto month = fmt::month(1);
auto day = fmt::day(1);
EXPECT_EQ(fmt::format("{}", year), "2024");
EXPECT_EQ(fmt::format("{}", month), "Jan");
EXPECT_EQ(fmt::format("{}", day), "01");
}