OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This is a "No Compile Test" suite. | 5 // This is a "No Compile Test" suite. |
6 // http://dev.chromium.org/developers/testing/no-compile-tests | 6 // http://dev.chromium.org/developers/testing/no-compile-tests |
7 | 7 |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 | 11 |
12 #if defined(NCTEST_DIFFERENT_ENUM) // [r"\|sample\| and \|boundary\| shouldn't
be of different enums"] | 12 #if defined(NCTEST_DIFFERENT_ENUM) // [r"\|sample\| and \|boundary\| shouldn't
be of different enums"] |
13 | 13 |
14 void WontCompile() { | 14 void WontCompile() { |
15 enum TypeA { A }; | 15 enum TypeA { A }; |
16 enum TypeB { B }; | 16 enum TypeB { B }; |
17 UMA_HISTOGRAM_ENUMERATION("", A, B); | 17 UMA_HISTOGRAM_ENUMERATION("", A, B); |
18 } | 18 } |
19 | 19 |
| 20 #elif defined(NCTEST_DIFFERENT_ENUM_CLASS) // [r"\|sample\| and \|boundary\| sh
ouldn't be of different enums"] |
| 21 |
| 22 void WontCompile() { |
| 23 enum class TypeA { A }; |
| 24 enum class TypeB { B }; |
| 25 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeB::B); |
| 26 } |
| 27 |
| 28 #elif defined(NCTEST_DIFFERENT_ENUM_MIXED) // [r"\|sample\| and \|boundary\| sh
ouldn't be of different enums"] |
| 29 |
| 30 void WontCompile() { |
| 31 enum class TypeA { A }; |
| 32 enum TypeB { B }; |
| 33 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, B); |
| 34 } |
| 35 |
20 #elif defined(NCTEST_NEGATIVE_ENUM_MAX) // [r'static_assert failed "\|boundary\
| is out of range of HistogramBase::Sample"'] | 36 #elif defined(NCTEST_NEGATIVE_ENUM_MAX) // [r'static_assert failed "\|boundary\
| is out of range of HistogramBase::Sample"'] |
21 | 37 |
22 void WontCompile() { | 38 void WontCompile() { |
23 // Buckets for enumeration start from 0, so a boundary < 0 is illegal. | 39 // Buckets for enumeration start from 0, so a boundary < 0 is illegal. |
24 enum class TypeA { A = -1 }; | 40 enum class TypeA { A = -1 }; |
25 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); | 41 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); |
26 } | 42 } |
27 | 43 |
28 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound
ary\| is out of range of HistogramBase::Sample"'] | 44 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound
ary\| is out of range of HistogramBase::Sample"'] |
29 | 45 |
30 void WontCompile() { | 46 void WontCompile() { |
31 // HistogramBase::Sample is an int and can't hold larger values. | 47 // HistogramBase::Sample is an int and can't hold larger values. |
32 enum class TypeA : uint32_t { A = 0xffffffff }; | 48 enum class TypeA : uint32_t { A = 0xffffffff }; |
33 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); | 49 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); |
34 } | 50 } |
35 | 51 |
36 #endif | 52 #endif |
37 | 53 |
38 } // namespace base | 54 } // namespace base |
OLD | NEW |