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

Unified Diff: base/metrics/sparse_histogram_unittest.cc

Issue 11022002: Add SampleMap and use it in SparseHistogram (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address more comments Created 8 years, 2 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/sparse_histogram.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/sparse_histogram_unittest.cc
diff --git a/base/metrics/sparse_histogram_unittest.cc b/base/metrics/sparse_histogram_unittest.cc
index 1ed0e7131546fdeccf32810bc0a56a7555d202c6..2fe614fe6ae1c50697c36c8cc5d3140a3a362c39 100644
--- a/base/metrics/sparse_histogram_unittest.cc
+++ b/base/metrics/sparse_histogram_unittest.cc
@@ -5,6 +5,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "base/metrics/sample_map.h"
#include "base/metrics/sparse_histogram.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,22 +20,21 @@ class SparseHistogramTest : public testing::Test {
TEST_F(SparseHistogramTest, BasicTest) {
scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse1"));
- std::map<HistogramBase::Sample, HistogramBase::Count> sample;
- histogram->SnapshotSample(&sample);
-
- ASSERT_EQ(0u, sample.size());
+ scoped_ptr<SampleMap> snapshot(histogram->SnapshotSamples());
+ EXPECT_EQ(0, snapshot->TotalCount());
+ EXPECT_EQ(0, snapshot->sum());
histogram->Add(100);
- histogram->SnapshotSample(&sample);
- ASSERT_EQ(1u, sample.size());
- EXPECT_EQ(1, sample[100]);
+ scoped_ptr<SampleMap> snapshot1(histogram->SnapshotSamples());
+ EXPECT_EQ(1, snapshot1->TotalCount());
+ EXPECT_EQ(1, snapshot1->GetCount(100));
histogram->Add(100);
histogram->Add(101);
- histogram->SnapshotSample(&sample);
- ASSERT_EQ(2u, sample.size());
- EXPECT_EQ(2, sample[100]);
- EXPECT_EQ(1, sample[101]);
+ scoped_ptr<SampleMap> snapshot2(histogram->SnapshotSamples());
+ EXPECT_EQ(3, snapshot2->TotalCount());
+ EXPECT_EQ(2, snapshot2->GetCount(100));
+ EXPECT_EQ(1, snapshot2->GetCount(101));
}
} // namespace base
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698