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_functions.h" |
8 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
9 | 10 |
10 namespace base { | 11 namespace base { |
11 | 12 |
12 #if defined(NCTEST_DIFFERENT_ENUM) // [r"\|sample\| and \|boundary\| shouldn't
be of different enums"] | 13 #if defined(NCTEST_DIFFERENT_ENUM) // [r"\|sample\| and \|boundary\| shouldn't
be of different enums"] |
13 | 14 |
14 void WontCompile() { | 15 void WontCompile() { |
15 enum TypeA { A }; | 16 enum TypeA { A }; |
16 enum TypeB { B }; | 17 enum TypeB { B }; |
17 UMA_HISTOGRAM_ENUMERATION("", A, B); | 18 UMA_HISTOGRAM_ENUMERATION("", A, B); |
18 } | 19 } |
19 | 20 |
20 #elif defined(NCTEST_NEGATIVE_ENUM_MAX) // [r'static_assert failed "\|boundary\
| is out of range of HistogramBase::Sample"'] | 21 #elif defined(NCTEST_NEGATIVE_ENUM_MAX) // [r'static_assert failed "\|boundary\
| is out of range of HistogramBase::Sample"'] |
21 | 22 |
22 void WontCompile() { | 23 void WontCompile() { |
23 // Buckets for enumeration start from 0, so a boundary < 0 is illegal. | 24 // Buckets for enumeration start from 0, so a boundary < 0 is illegal. |
24 enum class TypeA { A = -1 }; | 25 enum class TypeA { A = -1 }; |
25 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); | 26 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); |
26 } | 27 } |
27 | 28 |
28 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound
ary\| is out of range of HistogramBase::Sample"'] | 29 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound
ary\| is out of range of HistogramBase::Sample"'] |
29 | 30 |
30 void WontCompile() { | 31 void WontCompile() { |
31 // HistogramBase::Sample is an int and can't hold larger values. | 32 // HistogramBase::Sample is an int and can't hold larger values. |
32 enum class TypeA : uint32_t { A = 0xffffffff }; | 33 enum class TypeA : uint32_t { A = 0xffffffff }; |
33 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); | 34 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); |
34 } | 35 } |
35 | 36 |
| 37 #elif defined(NCTEST_FUNCTION_INT) // [r"Non enum passed to UmaHistogramEnumera
tion"] |
| 38 |
| 39 void WontCompile() { |
| 40 UmaHistogramEnumeration("", 1, 2); |
| 41 } |
| 42 |
| 43 #elif defined(NCTEST_FUNCTION_DIFFERENT_ENUM) // [r"no matching function for ca
ll to 'UmaHistogramEnumeration'"] |
| 44 |
| 45 void WontCompile() { |
| 46 enum TypeA { A }; |
| 47 enum TypeB { B }; |
| 48 UmaHistogramEnumeration("", A, B); |
| 49 } |
| 50 |
| 51 #elif defined(NCTEST_FUNCTION_FIRST_NOT_ENUM) // [r"no matching function for ca
ll to 'UmaHistogramEnumeration'"] |
| 52 |
| 53 void WontCompile() { |
| 54 enum TypeB { B }; |
| 55 UmaHistogramEnumeration("", 1, B); |
| 56 } |
| 57 |
| 58 #elif defined(NCTEST_FUNCTION_SECOND_NOT_ENUM) // [r"no matching function for c
all to 'UmaHistogramEnumeration'"] |
| 59 |
| 60 void WontCompile() { |
| 61 enum TypeA { A }; |
| 62 UmaHistogramEnumeration("", A, 2); |
| 63 } |
| 64 |
36 #endif | 65 #endif |
37 | 66 |
38 } // namespace base | 67 } // namespace base |
OLD | NEW |