| Index: base/metrics/sample_map_unittest.cc
|
| diff --git a/base/metrics/sample_map_unittest.cc b/base/metrics/sample_map_unittest.cc
|
| index 1a53ee7f546b38525c8c4b2836fb3649ca74cc38..22ce8e1c8e3ab3a347af2e008ce622bb662cd67d 100644
|
| --- a/base/metrics/sample_map_unittest.cc
|
| +++ b/base/metrics/sample_map_unittest.cc
|
| @@ -2,8 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "base/memory/scoped_ptr.h"
|
| #include "base/metrics/sample_map.h"
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace base {
|
| @@ -86,10 +87,43 @@ TEST(SampleMapIteratorTest, IterateTest) {
|
| EXPECT_EQ(-300, count);
|
|
|
| it->Next();
|
| + EXPECT_TRUE(it->Done());
|
| +}
|
| +
|
| +TEST(SampleMapIteratorTest, SkipEmptyRanges) {
|
| + SampleMap samples;
|
| + samples.Accumulate(5, 1);
|
| + samples.Accumulate(10, 2);
|
| + samples.Accumulate(15, 3);
|
| + samples.Accumulate(20, 4);
|
| + samples.Accumulate(25, 5);
|
| +
|
| + SampleMap samples2;
|
| + samples2.Accumulate(5, 1);
|
| + samples2.Accumulate(20, 4);
|
| + samples2.Accumulate(25, 5);
|
| +
|
| + samples.Subtract(samples2);
|
| +
|
| + scoped_ptr<SampleCountIterator> it = samples.Iterator();
|
| + EXPECT_FALSE(it->Done());
|
| +
|
| + HistogramBase::Sample min;
|
| + HistogramBase::Sample max;
|
| + HistogramBase::Count count;
|
| +
|
| + it->Get(&min, &max, &count);
|
| + EXPECT_EQ(10, min);
|
| + EXPECT_EQ(11, max);
|
| + EXPECT_EQ(2, count);
|
| +
|
| + it->Next();
|
| + EXPECT_FALSE(it->Done());
|
| +
|
| it->Get(&min, &max, &count);
|
| - EXPECT_EQ(5, min);
|
| - EXPECT_EQ(6, max);
|
| - EXPECT_EQ(0, count);
|
| + EXPECT_EQ(15, min);
|
| + EXPECT_EQ(16, max);
|
| + EXPECT_EQ(3, count);
|
|
|
| it->Next();
|
| EXPECT_TRUE(it->Done());
|
|
|