add FOLLY_SANITIZE macro
[folly.git] / folly / stats / test / HistogramTest.cpp
index c2997a35ecdf5e55a44d18e24924d47a6298d884..7f6b4f1f339b4b3f46913a1b52a8abd8e1ee61dc 100644 (file)
@@ -15,9 +15,9 @@
  */
 
 #include <folly/stats/Histogram.h>
-#include <folly/stats/Histogram-defs.h>
 
 #include <folly/portability/GTest.h>
+#include <folly/stats/Histogram-defs.h>
 
 using folly::Histogram;
 
@@ -42,8 +42,8 @@ TEST(Histogram, Test100) {
     if (n < 100) {
       double lowPct = -1.0;
       double highPct = -1.0;
-      unsigned int bucketIdx = h.getPercentileBucketIdx(pct + epsilon,
-                                                        &lowPct, &highPct);
+      unsigned int bucketIdx =
+          h.getPercentileBucketIdx(pct + epsilon, &lowPct, &highPct);
       EXPECT_EQ(n + 1, bucketIdx);
       EXPECT_FLOAT_EQ(n / 100.0, lowPct);
       EXPECT_FLOAT_EQ((n + 1) / 100.0, highPct);
@@ -53,8 +53,8 @@ TEST(Histogram, Test100) {
     if (n > 0) {
       double lowPct = -1.0;
       double highPct = -1.0;
-      unsigned int bucketIdx = h.getPercentileBucketIdx(pct - epsilon,
-                                                        &lowPct, &highPct);
+      unsigned int bucketIdx =
+          h.getPercentileBucketIdx(pct - epsilon, &lowPct, &highPct);
       EXPECT_EQ(n, bucketIdx);
       EXPECT_FLOAT_EQ((n - 1) / 100.0, lowPct);
       EXPECT_FLOAT_EQ(n / 100.0, highPct);
@@ -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
@@ -212,7 +212,7 @@ TEST(Histogram, Counts) {
   // Add one to each bucket, make sure the counts match
   for (int32_t i = 0; i < 10; i++) {
     h.addValue(i);
-    EXPECT_EQ(i+1, h.computeTotalCount());
+    EXPECT_EQ(i + 1, h.computeTotalCount());
   }
 
   // Add a lot to one bucket, make sure the counts still make sense