Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2041)

Unified Diff: base/metrics/sample_map_unittest.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/sample_map.cc ('k') | base/metrics/sample_vector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « base/metrics/sample_map.cc ('k') | base/metrics/sample_vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698