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

Unified Diff: base/metrics/histogram_unittest.nc

Issue 2776853002: Make UMA_HISTOGRAM_ENUMERATION work with scoped enums. (Closed)
Patch Set: rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/metrics/histogram_unittest.nc
diff --git a/base/metrics/histogram_unittest.nc b/base/metrics/histogram_unittest.nc
index 0dfe1af050accf102a4fbb3fb484825183f1d4a3..6f913e89f1475ca2dfa3a94317eaea2db9f7a674 100644
--- a/base/metrics/histogram_unittest.nc
+++ b/base/metrics/histogram_unittest.nc
@@ -17,6 +17,22 @@ void WontCompile() {
UMA_HISTOGRAM_ENUMERATION("", A, B);
}
+#elif defined(NCTEST_NEGATIVE_ENUM_MAX) // [r'static_assert failed "\|boundary\| is out of range of HistogramBase::Sample"']
+
+void WontCompile() {
+ // Buckets for enumeration start from 0, so a boundary < 0 is illegal.
+ enum class TypeA { A = -1 };
+ UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A);
+}
+
+#elif defined(NCTEST_ENUM_MAX_OUT_OF_RANGE) // [r'static_assert failed "\|boundary\| is out of range of HistogramBase::Sample"']
+
+void WontCompile() {
+ // HistogramBase::Sample is an int and can't hold larger values.
+ enum class TypeA : uint32_t { A = 0xffffffff };
+ UMA_HISTOGRAM_ENUMERATION("", TypeA::A, TypeA::A);
+}
+
#endif
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698