Add FMT_ASSERT and validation of values of struct tm members (#2564)

Switch internal year calculations to long long
This commit is contained in:
Vladislav Shchapov
2021-10-28 01:29:07 +05:00
committed by GitHub
parent df40e94673
commit 90034e4c4b
2 changed files with 99 additions and 58 deletions

View File

@@ -93,6 +93,13 @@ TEST(chrono_test, format_tm) {
EXPECT_EQ(fmt::format("{:%Y}", tm), "0027");
EXPECT_EQ(fmt::format("{:%C%y}", tm), "0027");
// Overflow year
tm.tm_year = 2147483647;
EXPECT_EQ(fmt::format("{:%Y}", tm), "2147485547");
tm.tm_year = -2147483648;
EXPECT_EQ(fmt::format("{:%Y}", tm), "-2147481748");
// for week on the year
// https://www.cl.cam.ac.uk/~mgk25/iso-time.html
std::vector<std::tm> tm_list = {