summaryrefslogtreecommitdiffstats
path: root/googletest/test/googletest-printers-test.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-11-16 17:17:58 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-11-16 17:18:37 (GMT)
commit9c332145b71c36a5bad9688312c79184f98601ff (patch)
treef465e472334c8dd173ff3cfb76823ed1f18a7f36 /googletest/test/googletest-printers-test.cc
parent4408a0288b24fbe9156a9b14bbecd148ea64f40f (diff)
downloadgoogletest-9c332145b71c36a5bad9688312c79184f98601ff.zip
googletest-9c332145b71c36a5bad9688312c79184f98601ff.tar.gz
googletest-9c332145b71c36a5bad9688312c79184f98601ff.tar.bz2
When printing floating-point numbers, print full precision by default.
To make debug output readable, we still use the faster 6-digit precision sometimes, but only if it will round-trip. This way, when a test fails due to a very small difference in floating-point numbers, users will have enough digits to see the difference. PiperOrigin-RevId: 488958311 Change-Id: Ibcac43f48a97006d89217530c69386cc4fa2735c
Diffstat (limited to 'googletest/test/googletest-printers-test.cc')
-rw-r--r--googletest/test/googletest-printers-test.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index d2d88a5..8a7db25 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -458,7 +458,15 @@ TEST(PrintBuiltInTypeTest, Int128) {
// Floating-points.
TEST(PrintBuiltInTypeTest, FloatingPoints) {
- EXPECT_EQ("1.5", Print(1.5f)); // float
+ // float (32-bit precision)
+ EXPECT_EQ("1.5", Print(1.5f));
+
+ EXPECT_EQ("1.0999999", Print(1.09999990f));
+ EXPECT_EQ("1.1", Print(1.10000002f));
+ EXPECT_EQ("1.10000014", Print(1.10000014f));
+ EXPECT_EQ("9e+09", Print(9e9f));
+
+ // double
EXPECT_EQ("-2.5", Print(-2.5)); // double
}