1 // Copyright 2018 The Chromium Authors. All rights reserved. 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 "base/optional.h" 8 #include "testing/gtest/include/gtest/gtest.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 Optional<HistogramEnumEntryMap> results = ReadEnumFromEnumsXml("Boolean"); 19 ASSERT_TRUE(results); 20 EXPECT_EQ("False", results->at(0)); 21 EXPECT_EQ("True", results->at(1)); 22 } 23 24 { 25 Optional<HistogramEnumEntryMap> results = 26 ReadEnumFromEnumsXml("TheWorstNameForAnEnum"); 27 ASSERT_FALSE(results); 28 } 29 } 30 31 } // namespace base 32