| OLD | NEW |
| 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" | 5 #include "base/metrics/sample_vector.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 std::vector<HistogramBase::Count> counts(3); | 208 std::vector<HistogramBase::Count> counts(3); |
| 209 counts[0] = 1; | 209 counts[0] = 1; |
| 210 counts[1] = 0; // Iterator will bypass this empty bucket. | 210 counts[1] = 0; // Iterator will bypass this empty bucket. |
| 211 counts[2] = 2; | 211 counts[2] = 2; |
| 212 | 212 |
| 213 // BucketRanges can have larger size than counts. | 213 // BucketRanges can have larger size than counts. |
| 214 SampleVectorIterator it(&counts, &ranges); | 214 SampleVectorIterator it(&counts, &ranges); |
| 215 size_t index; | 215 size_t index; |
| 216 | 216 |
| 217 HistogramBase::Sample min; | 217 HistogramBase::Sample min; |
| 218 HistogramBase::Sample max; | 218 int64_t max; |
| 219 HistogramBase::Count count; | 219 HistogramBase::Count count; |
| 220 it.Get(&min, &max, &count); | 220 it.Get(&min, &max, &count); |
| 221 EXPECT_EQ(0, min); | 221 EXPECT_EQ(0, min); |
| 222 EXPECT_EQ(1, max); | 222 EXPECT_EQ(1, max); |
| 223 EXPECT_EQ(1, count); | 223 EXPECT_EQ(1, count); |
| 224 EXPECT_TRUE(it.GetBucketIndex(&index)); | 224 EXPECT_TRUE(it.GetBucketIndex(&index)); |
| 225 EXPECT_EQ(0u, index); | 225 EXPECT_EQ(0u, index); |
| 226 | 226 |
| 227 it.Next(); | 227 it.Next(); |
| 228 it.Get(&min, &max, &count); | 228 it.Get(&min, &max, &count); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 ranges.set_range(2, 2); | 264 ranges.set_range(2, 2); |
| 265 ranges.set_range(3, 3); | 265 ranges.set_range(3, 3); |
| 266 ranges.set_range(4, INT_MAX); | 266 ranges.set_range(4, INT_MAX); |
| 267 SampleVector samples(1, &ranges); | 267 SampleVector samples(1, &ranges); |
| 268 | 268 |
| 269 std::unique_ptr<SampleCountIterator> it = samples.Iterator(); | 269 std::unique_ptr<SampleCountIterator> it = samples.Iterator(); |
| 270 | 270 |
| 271 EXPECT_TRUE(it->Done()); | 271 EXPECT_TRUE(it->Done()); |
| 272 | 272 |
| 273 HistogramBase::Sample min; | 273 HistogramBase::Sample min; |
| 274 HistogramBase::Sample max; | 274 int64_t max; |
| 275 HistogramBase::Count count; | 275 HistogramBase::Count count; |
| 276 EXPECT_DCHECK_DEATH(it->Get(&min, &max, &count)); | 276 EXPECT_DCHECK_DEATH(it->Get(&min, &max, &count)); |
| 277 | 277 |
| 278 EXPECT_DCHECK_DEATH(it->Next()); | 278 EXPECT_DCHECK_DEATH(it->Next()); |
| 279 | 279 |
| 280 samples.Accumulate(2, 100); | 280 samples.Accumulate(2, 100); |
| 281 it = samples.Iterator(); | 281 it = samples.Iterator(); |
| 282 EXPECT_FALSE(it->Done()); | 282 EXPECT_FALSE(it->Done()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace | 285 } // namespace |
| 286 } // namespace base | 286 } // namespace base |
| OLD | NEW |