Don't emit more than precision digits (#1072)

This commit is contained in:
Victor Zverovich
2019-03-09 13:53:23 -08:00
parent 3466d9c845
commit 49d244c065
3 changed files with 16 additions and 6 deletions

View File

@@ -1470,6 +1470,10 @@ TEST(FormatterTest, FormatDouble) {
EXPECT_EQ(buffer, format("{:A}", -42.0));
}
TEST(FormatterTest, PrecisionRounding) {
EXPECT_EQ("0.000", format("{:.3f}", 0.00049));
}
TEST(FormatterTest, FormatNaN) {
double nan = std::numeric_limits<double>::quiet_NaN();
EXPECT_EQ("nan", format("{}", nan));