xref: /openbmc/phosphor-logging/test/openpower-pels/pel_values_test.cpp (revision 242be740393b9714caa51c6f9dc0da4b9a513aec)
197f7abcfSMatt Spinler /**
297f7abcfSMatt Spinler  * Copyright © 2019 IBM Corporation
397f7abcfSMatt Spinler  *
497f7abcfSMatt Spinler  * Licensed under the Apache License, Version 2.0 (the "License");
597f7abcfSMatt Spinler  * you may not use this file except in compliance with the License.
697f7abcfSMatt Spinler  * You may obtain a copy of the License at
797f7abcfSMatt Spinler  *
897f7abcfSMatt Spinler  *     http://www.apache.org/licenses/LICENSE-2.0
997f7abcfSMatt Spinler  *
1097f7abcfSMatt Spinler  * Unless required by applicable law or agreed to in writing, software
1197f7abcfSMatt Spinler  * distributed under the License is distributed on an "AS IS" BASIS,
1297f7abcfSMatt Spinler  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1397f7abcfSMatt Spinler  * See the License for the specific language governing permissions and
1497f7abcfSMatt Spinler  * limitations under the License.
1597f7abcfSMatt Spinler  */
16835a8693SMatt Spinler #include "extensions/openpower-pels/pel_values.hpp"
17835a8693SMatt Spinler 
18835a8693SMatt Spinler #include <gtest/gtest.h>
19835a8693SMatt Spinler 
20578e070fSMatt Spinler using namespace openpower::pels;
21835a8693SMatt Spinler using namespace openpower::pels::pel_values;
22835a8693SMatt Spinler 
TEST(PELFieldsTest,TestFindFields)23835a8693SMatt Spinler TEST(PELFieldsTest, TestFindFields)
24835a8693SMatt Spinler {
25835a8693SMatt Spinler     auto s = findByValue(0x5D, subsystemValues);
26835a8693SMatt Spinler     ASSERT_NE(s, subsystemValues.end());
27b181d9d1SMatt Spinler     EXPECT_EQ(0x5D, std::get<fieldValuePos>(*s));
28b181d9d1SMatt Spinler     EXPECT_STREQ("cec_service_network", std::get<registryNamePos>(*s));
29835a8693SMatt Spinler 
30835a8693SMatt Spinler     s = findByName("cec_clocks", subsystemValues);
31835a8693SMatt Spinler     ASSERT_NE(s, subsystemValues.end());
32b181d9d1SMatt Spinler     EXPECT_EQ(0x58, std::get<fieldValuePos>(*s));
33b181d9d1SMatt Spinler     EXPECT_STREQ("cec_clocks", std::get<registryNamePos>(*s));
34*242be740SVijay Lobo     EXPECT_STREQ("CEC Hardware - Clock", std::get<descriptionPos>(*s));
35835a8693SMatt Spinler 
36835a8693SMatt Spinler     s = findByValue(0xFF, subsystemValues);
37b181d9d1SMatt Spinler     EXPECT_EQ(s, subsystemValues.end());
38835a8693SMatt Spinler 
39835a8693SMatt Spinler     s = findByName("foo", subsystemValues);
40b181d9d1SMatt Spinler     EXPECT_EQ(s, subsystemValues.end());
41835a8693SMatt Spinler }
42