Index: base/metrics/histogram_unittest.cc |
diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc |
index 58b72480018591f72679a6e1ff036727f25ada2c..668ac1ba7e83ad47bfd107beb97e407bff57d1a8 100644 |
--- a/base/metrics/histogram_unittest.cc |
+++ b/base/metrics/histogram_unittest.cc |
@@ -147,7 +147,7 @@ TEST_P(HistogramTest, NameMatchTest) { |
EXPECT_EQ(2, samples->GetCount(10)); |
} |
-// Check that delta calculations work correct. |
+// Check that delta calculations work correctly. |
TEST_P(HistogramTest, DeltaTest) { |
HistogramBase* histogram = |
Histogram::FactoryGet("DeltaHistogram", 1, 64, 8, |
@@ -176,6 +176,32 @@ TEST_P(HistogramTest, DeltaTest) { |
EXPECT_EQ(0, samples->TotalCount()); |
} |
+// Check that final-delta calculations work correctly. |
+TEST_P(HistogramTest, FinalDeltaTest) { |
+ HistogramBase* histogram = |
+ Histogram::FactoryGet("FinalDeltaHistogram", 1, 64, 8, |
+ HistogramBase::kNoFlags); |
+ histogram->Add(1); |
+ histogram->Add(10); |
+ histogram->Add(50); |
+ |
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotDelta(); |
+ EXPECT_EQ(3, samples->TotalCount()); |
+ EXPECT_EQ(1, samples->GetCount(1)); |
+ EXPECT_EQ(1, samples->GetCount(10)); |
+ EXPECT_EQ(1, samples->GetCount(50)); |
+ EXPECT_EQ(samples->TotalCount(), samples->redundant_count()); |
+ |
+ histogram->Add(2); |
+ histogram->Add(50); |
+ |
+ samples = histogram->SnapshotFinalDelta(); |
+ EXPECT_EQ(2, samples->TotalCount()); |
+ EXPECT_EQ(1, samples->GetCount(2)); |
+ EXPECT_EQ(1, samples->GetCount(50)); |
+ EXPECT_EQ(samples->TotalCount(), samples->redundant_count()); |
+} |
+ |
TEST_P(HistogramTest, ExponentialRangesTest) { |
// Check that we got a nice exponential when there was enough room. |
BucketRanges ranges(9); |