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

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

Issue 2776853002: Make UMA_HISTOGRAM_ENUMERATION work with scoped enums. (Closed)
Patch Set: rebase Created 3 years, 8 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_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_NEGATIVE_ENUM_MAX) // [r'static_assert failed "\|boundary\ | is out of range of HistogramBase::Sample"']
21
22 void WontCompile() {
23 // Buckets for enumeration start from 0, so a boundary < 0 is illegal.
24 enum class TypeA { A = -1 };
25 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A);
26 }
27
28 #elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|bound ary\| is out of range of HistogramBase::Sample"']
29
30 void WontCompile() {
31 // HistogramBase::Sample is an int and can't hold larger values.
32 enum class TypeA : uint32_t { A = 0xffffffff };
33 UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A);
34 }
35
20 #endif 36 #endif
21 37
22 } // namespace base 38 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698