| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/metrics/histogram_encoder.h" | 5 #include "components/metrics/histogram_encoder.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/metrics/bucket_ranges.h" | 9 #include "base/metrics/bucket_ranges.h" |
| 11 #include "base/metrics/sample_vector.h" | 10 #include "base/metrics/sample_vector.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 12 |
| 14 namespace metrics { | 13 namespace metrics { |
| 15 | 14 |
| 16 TEST(HistogramEncoder, HistogramBucketFields) { | 15 TEST(HistogramEncoder, HistogramBucketFields) { |
| 17 // Create buckets: 1-5, 5-7, 7-8, 8-9, 9-10, 10-11, 11-12. | 16 // Create buckets: 1-5, 5-7, 7-8, 8-9, 9-10, 10-11, 11-12. |
| 18 base::BucketRanges ranges(8); | 17 base::BucketRanges ranges(8); |
| 19 ranges.set_range(0, 1); | 18 ranges.set_range(0, 1); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 EXPECT_FALSE(histogram_proto.bucket(3).has_max()); | 62 EXPECT_FALSE(histogram_proto.bucket(3).has_max()); |
| 64 EXPECT_EQ(10, histogram_proto.bucket(3).min()); | 63 EXPECT_EQ(10, histogram_proto.bucket(3).min()); |
| 65 | 64 |
| 66 // 11-12 becomes /-12 (last record must keep max, min is same as max - 1). | 65 // 11-12 becomes /-12 (last record must keep max, min is same as max - 1). |
| 67 EXPECT_FALSE(histogram_proto.bucket(4).has_min()); | 66 EXPECT_FALSE(histogram_proto.bucket(4).has_min()); |
| 68 EXPECT_TRUE(histogram_proto.bucket(4).has_max()); | 67 EXPECT_TRUE(histogram_proto.bucket(4).has_max()); |
| 69 EXPECT_EQ(12, histogram_proto.bucket(4).max()); | 68 EXPECT_EQ(12, histogram_proto.bucket(4).max()); |
| 70 } | 69 } |
| 71 | 70 |
| 72 } // namespace metrics | 71 } // namespace metrics |
| OLD | NEW |