From 5bcd642bccba950216f368afd8f6dd3139577c3b Mon Sep 17 00:00:00 2001 From: andargunov Date: Tue, 6 Oct 2020 17:16:42 +0300 Subject: [PATCH] Added EXPECT expressions for the situation described in issue #1917, as well as for similar situations. format("{:.1e}", 1e-12) Actual: 1.00e-12 Expected: 1.0e-12 --- test/format-test.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/format-test.cc b/test/format-test.cc index 911d1d58..f6fcd4d4 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -958,6 +958,10 @@ TEST(FormatterTest, Precision) { EXPECT_EQ("1019666400", format("{}", 1019666432.0f)); EXPECT_EQ("1e+01", format("{:.0e}", 9.5)); + EXPECT_EQ("1.0e-02", format("{:.1e}", 1e-2)); + EXPECT_EQ("1.0e-12", format("{:.1e}", 1e-12)); + EXPECT_EQ("1.0e+12", format("{:.1e}", 1e12)); + EXPECT_THROW_MSG(format("{0:.2}", reinterpret_cast(0xcafe)), format_error, "precision not allowed for this argument type");