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

Side by Side Diff: base/metrics/histogram_unittest.nc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 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
OLDNEW
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_functions.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound ary\| is out of range of HistogramBase::Sample"'] 45 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound ary\| is out of range of HistogramBase::Sample"']
46 46
47 void WontCompile() { 47 void WontCompile() {
48 // HistogramBase::Sample is an int and can't hold larger values. 48 // HistogramBase::Sample is an int and can't hold larger values.
49 enum class TypeA : uint32_t { A = 0xffffffff }; 49 enum class TypeA : uint32_t { A = 0xffffffff };
50 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A); 50 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A);
51 } 51 }
52 52
53 #elif defined(NCTEST_SAMPLE_NOT_ENUM) // [r'static_assert failed "Unexpected: \ |boundary\| is enum, but \|sample\| is not."']
54
55 void WontCompile() {
56 enum TypeA { A };
57 UMA_HISTOGRAM_ENUMERATION("", 0, TypeA::A);
58 }
59
53 #elif defined(NCTEST_FUNCTION_INT) // [r"Non enum passed to UmaHistogramEnumera tion"] 60 #elif defined(NCTEST_FUNCTION_INT) // [r"Non enum passed to UmaHistogramEnumera tion"]
54 61
55 void WontCompile() { 62 void WontCompile() {
56 UmaHistogramEnumeration("", 1, 2); 63 UmaHistogramEnumeration("", 1, 2);
57 } 64 }
58 65
59 #elif defined(NCTEST_FUNCTION_DIFFERENT_ENUM) // [r"no matching function for ca ll to 'UmaHistogramEnumeration'"] 66 #elif defined(NCTEST_FUNCTION_DIFFERENT_ENUM) // [r"no matching function for ca ll to 'UmaHistogramEnumeration'"]
60 67
61 void WontCompile() { 68 void WontCompile() {
62 enum TypeA { A }; 69 enum TypeA { A };
(...skipping 11 matching lines...) Expand all
74 #elif defined(NCTEST_FUNCTION_SECOND_NOT_ENUM) // [r"no matching function for c all to 'UmaHistogramEnumeration'"] 81 #elif defined(NCTEST_FUNCTION_SECOND_NOT_ENUM) // [r"no matching function for c all to 'UmaHistogramEnumeration'"]
75 82
76 void WontCompile() { 83 void WontCompile() {
77 enum TypeA { A }; 84 enum TypeA { A };
78 UmaHistogramEnumeration("", A, 2); 85 UmaHistogramEnumeration("", A, 2);
79 } 86 }
80 87
81 #endif 88 #endif
82 89
83 } // namespace base 90 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_macros_internal.h ('k') | chrome/browser/android/metrics/launch_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698