mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-01 22:20:06 +00:00
Fix overflow error (#3143)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru> Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
51d3685efe
commit
cd7202e039
@ -1838,7 +1838,7 @@ struct chrono_formatter {
|
|||||||
} else {
|
} else {
|
||||||
write(second(), 2);
|
write(second(), 2);
|
||||||
write_fractional_seconds<char_type>(
|
write_fractional_seconds<char_type>(
|
||||||
out, std::chrono::duration<Rep, Period>(val));
|
out, std::chrono::duration<rep, Period>(val));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -642,6 +642,15 @@ TEST(chrono_test, cpp20_duration_subsecond_support) {
|
|||||||
std::chrono::duration<long long, std::ratio<1, 7>>(1)),
|
std::chrono::duration<long long, std::ratio<1, 7>>(1)),
|
||||||
"00.142857");
|
"00.142857");
|
||||||
|
|
||||||
|
EXPECT_EQ(fmt::format("{:%S}",
|
||||||
|
std::chrono::duration<char, std::ratio<1, 100>>(0x80)),
|
||||||
|
"-01.28");
|
||||||
|
|
||||||
|
EXPECT_EQ(
|
||||||
|
fmt::format("{:%M:%S}",
|
||||||
|
std::chrono::duration<short, std::ratio<1, 100>>(0x8000)),
|
||||||
|
"-05:27.68");
|
||||||
|
|
||||||
// Check that floating point seconds with ratio<1,1> are printed.
|
// Check that floating point seconds with ratio<1,1> are printed.
|
||||||
EXPECT_EQ(fmt::format("{:%S}", std::chrono::duration<double>{1.5}),
|
EXPECT_EQ(fmt::format("{:%S}", std::chrono::duration<double>{1.5}),
|
||||||
"01.500000");
|
"01.500000");
|
||||||
|
Loading…
Reference in New Issue
Block a user