Fix overflow for chrono durations (#2722)

This commit is contained in:
matrackif authored and GitHub committed 2022-01-17 12:14:59 -08:00
1 parent 8f8a1a02d5
commit 5985f0a7d2
2 files changed
+23 -9

No files matched your search

+4
View File
@@ -623,6 +623,10 @@ TEST(chrono_test, cpp20_duration_subsecond_support) {
// fixed precision, and print zeros even if there is no fractional part.
EXPECT_EQ(fmt::format("{:%S}", std::chrono::microseconds{7000000}),
"07.000000");
EXPECT_EQ(fmt::format("{:%S}", std::chrono::duration<long long, std::ratio<1, 3>>(1)),
"00.333333");
EXPECT_EQ(fmt::format("{:%S}", std::chrono::duration<long long, std::ratio<1, 7>>(1)),
"00.142857");
}
#endif // FMT_STATIC_THOUSANDS_SEPARATOR