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

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: Support redundant_count 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
« base/metrics/sparse_histogram.cc ('K') | « 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..497008146b764f0dc6d2b78113ca5099f99e5f89 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,18 @@ 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());
Ilya Sherman 2012/10/05 03:29:24 nit: Why did you remove the testcase covering an e
kaiwang 2012/10/05 04:02:38 Done.
histogram->Add(100);
- histogram->SnapshotSample(&sample);
- ASSERT_EQ(1u, sample.size());
- EXPECT_EQ(1, sample[100]);
+ scoped_ptr<SampleMap> snapshot(histogram->SnapshotSamples());
+ EXPECT_EQ(1, snapshot->TotalCount());
+ EXPECT_EQ(1, snapshot->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
« base/metrics/sparse_histogram.cc ('K') | « base/metrics/sparse_histogram.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698