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

Side by Side Diff: base/metrics/sparse_histogram_unittest.cc

Issue 10830156: Skeleton code of SparseHistogram (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/sparse_histogram.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace base {
12
13 class SparseHistogramTest : public testing::Test {
14 protected:
15 scoped_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) {
16 return scoped_ptr<SparseHistogram>(new SparseHistogram(name));
17 }
18 };
19
20 TEST_F(SparseHistogramTest, BasicTest) {
21 scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse1"));
22 std::map<HistogramBase::Sample, HistogramBase::Count> sample;
23 histogram->SnapshotSample(&sample);
24
25 ASSERT_EQ(0u, sample.size());
26
27 histogram->Add(100);
28 histogram->SnapshotSample(&sample);
29 ASSERT_EQ(1u, sample.size());
30 EXPECT_EQ(1, sample[100]);
31
32 histogram->Add(100);
33 histogram->Add(101);
34 histogram->SnapshotSample(&sample);
35 ASSERT_EQ(2u, sample.size());
36 EXPECT_EQ(2, sample[100]);
37 EXPECT_EQ(1, sample[101]);
38 }
39
40 } // namespace base
OLDNEW
« 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