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

Side by Side Diff: base/metrics/sample_vector_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 unified diff | Download patch
« no previous file with comments | « base/metrics/sample_vector.cc ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/sample_vector.h"
6
5 #include <vector> 7 #include <vector>
6 8
7 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/bucket_ranges.h" 10 #include "base/metrics/bucket_ranges.h"
9 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
10 #include "base/metrics/sample_vector.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using std::vector;
14
15 namespace base { 14 namespace base {
16 namespace { 15 namespace {
17 16
18 TEST(SampleVectorTest, AccumulateTest) { 17 TEST(SampleVectorTest, AccumulateTest) {
19 // Custom buckets: [1, 5) [5, 10) 18 // Custom buckets: [1, 5) [5, 10)
20 BucketRanges ranges(3); 19 BucketRanges ranges(3);
21 ranges.set_range(0, 1); 20 ranges.set_range(0, 1);
22 ranges.set_range(1, 5); 21 ranges.set_range(1, 5);
23 ranges.set_range(2, 10); 22 ranges.set_range(2, 10);
24 SampleVector samples(&ranges); 23 SampleVector samples(&ranges);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST 171 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST
173 172
174 TEST(SampleVectorIteratorTest, IterateTest) { 173 TEST(SampleVectorIteratorTest, IterateTest) {
175 BucketRanges ranges(5); 174 BucketRanges ranges(5);
176 ranges.set_range(0, 0); 175 ranges.set_range(0, 0);
177 ranges.set_range(1, 1); 176 ranges.set_range(1, 1);
178 ranges.set_range(2, 2); 177 ranges.set_range(2, 2);
179 ranges.set_range(3, 3); 178 ranges.set_range(3, 3);
180 ranges.set_range(4, 4); 179 ranges.set_range(4, 4);
181 180
182 vector<HistogramBase::Count> counts(3); 181 std::vector<HistogramBase::Count> counts(3);
183 counts[0] = 1; 182 counts[0] = 1;
184 counts[1] = 0; // Iterator will bypass this empty bucket. 183 counts[1] = 0; // Iterator will bypass this empty bucket.
185 counts[2] = 2; 184 counts[2] = 2;
186 185
187 // BucketRanges can have larger size than counts. 186 // BucketRanges can have larger size than counts.
188 SampleVectorIterator it(&counts, &ranges); 187 SampleVectorIterator it(&counts, &ranges);
189 size_t index; 188 size_t index;
190 189
191 HistogramBase::Sample min; 190 HistogramBase::Sample min;
192 HistogramBase::Sample max; 191 HistogramBase::Sample max;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 samples.Accumulate(2, 100); 255 samples.Accumulate(2, 100);
257 it = samples.Iterator(); 256 it = samples.Iterator();
258 EXPECT_FALSE(it->Done()); 257 EXPECT_FALSE(it->Done());
259 } 258 }
260 259
261 #endif 260 #endif
262 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST 261 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST
263 262
264 } // namespace 263 } // namespace
265 } // namespace base 264 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/sample_vector.cc ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698