1 // Copyright 2018 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/test/metrics/histogram_enum_reader.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "third_party/abseil-cpp/absl/types/optional.h" 9 10 namespace base { 11 TEST(HistogramEnumReaderTest,SanityChecks)12TEST(HistogramEnumReaderTest, SanityChecks) { 13 { 14 // NOTE: This results in a dependency on the enums.xml file, but to 15 // otherwise inject content would circumvent a lot of the logic of the 16 // method and add additional complexity. "Boolean" is hopefully a pretty 17 // stable enum. 18 absl::optional<HistogramEnumEntryMap> results = 19 ReadEnumFromEnumsXml("Boolean"); 20 ASSERT_TRUE(results); 21 EXPECT_EQ("False", results->at(0)); 22 EXPECT_EQ("True", results->at(1)); 23 } 24 25 { 26 absl::optional<HistogramEnumEntryMap> results = 27 ReadEnumFromEnumsXml("TheWorstNameForAnEnum"); 28 ASSERT_FALSE(results); 29 } 30 } 31 32 } // namespace base 33