From: Adam Simpkins Date: Wed, 5 Jul 2017 19:56:00 +0000 (-0700) Subject: fix double comparison in histogram test X-Git-Tag: v2017.07.10.00~7 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=737be952bfa29e479fb0a48aa48dbab00c4fc9c5;p=folly.git fix double comparison in histogram test Summary: The TestDoubleWidthTooBig test was performing an exact equality check on two double values. This equality check fails when run on 32-bit platforms. Replace the EXPECT_EQ() check with EXPECT_NEAR(), and simply check that the two values do not differ by more than 1e-14. Reviewed By: Orvid Differential Revision: D652767 fbshipit-source-id: 7bf7ed560a4180a2e2d07a6050d1df18e18d1eea --- diff --git a/folly/stats/test/HistogramTest.cpp b/folly/stats/test/HistogramTest.cpp index 12236212..7f6b4f1f 100644 --- a/folly/stats/test/HistogramTest.cpp +++ b/folly/stats/test/HistogramTest.cpp @@ -200,7 +200,7 @@ TEST(Histogram, TestDoubleWidthTooBig) { EXPECT_EQ(1, h.getBucketByIndex(0).count); h.addValue(7.5); EXPECT_EQ(1, h.getBucketByIndex(2).count); - EXPECT_EQ(3.0, h.getPercentileEstimate(0.5)); + EXPECT_NEAR(3.0, h.getPercentileEstimate(0.5), 1e-14); } // Test that we get counts right