| Index: base/metrics/histogram_unittest.cc
|
| diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc
|
| index 09f9106d09758837ce79ac15453bb5c198a3b9d8..81fb38c977ece78b7b0b6f006952665f55b1367f 100644
|
| --- a/base/metrics/histogram_unittest.cc
|
| +++ b/base/metrics/histogram_unittest.cc
|
| @@ -208,6 +208,34 @@ TEST_F(HistogramTest, NameMatchTest) {
|
| EXPECT_EQ(2, samples->GetCount(10));
|
| }
|
|
|
| +// Check that delta calculations work correct.
|
| +TEST_F(HistogramTest, DeltaTest) {
|
| + HistogramBase* histogram =
|
| + Histogram::FactoryGet("DeltaHistogram", 1, 64, 8,
|
| + HistogramBase::kNoFlags);
|
| + histogram->Add(1);
|
| + histogram->Add(10);
|
| + histogram->Add(50);
|
| +
|
| + scoped_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));
|
| +
|
| + samples = histogram->SnapshotDelta();
|
| + EXPECT_EQ(0, samples->TotalCount());
|
| +
|
| + histogram->Add(10);
|
| + histogram->Add(10);
|
| + samples = histogram->SnapshotDelta();
|
| + EXPECT_EQ(2, samples->TotalCount());
|
| + EXPECT_EQ(2, samples->GetCount(10));
|
| +
|
| + samples = histogram->SnapshotDelta();
|
| + EXPECT_EQ(0, samples->TotalCount());
|
| +}
|
| +
|
| TEST_F(HistogramTest, ExponentialRangesTest) {
|
| // Check that we got a nice exponential when there was enough room.
|
| BucketRanges ranges(9);
|
|
|