1 /**
2  * Copyright © 2020 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "pmbus_error.hpp"
17 
18 #include <gtest/gtest.h>
19 
20 using namespace phosphor::power::regulators;
21 
TEST(PMBusErrorTests,Constructor)22 TEST(PMBusErrorTests, Constructor)
23 {
24     PMBusError error(
25         "VOUT_MODE contains unsupported data format", "vdd_reg",
26         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
27     EXPECT_EQ(error.getDeviceID(), "vdd_reg");
28     EXPECT_EQ(error.getInventoryPath(),
29               "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
30     EXPECT_STREQ(error.what(),
31                  "PMBusError: VOUT_MODE contains unsupported data format");
32 }
33 
TEST(PMBusErrorTests,GetDeviceID)34 TEST(PMBusErrorTests, GetDeviceID)
35 {
36     PMBusError error(
37         "VOUT_MODE contains unsupported data format", "vdd_reg",
38         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
39     EXPECT_EQ(error.getDeviceID(), "vdd_reg");
40 }
41 
TEST(PMBusErrorTests,GetInventoryPath)42 TEST(PMBusErrorTests, GetInventoryPath)
43 {
44     PMBusError error(
45         "VOUT_MODE contains unsupported data format", "vdd_reg",
46         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
47     EXPECT_EQ(error.getInventoryPath(),
48               "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
49 }
50 
TEST(PMBusErrorTests,What)51 TEST(PMBusErrorTests, What)
52 {
53     PMBusError error(
54         "VOUT_MODE contains unsupported data format", "vdd_reg",
55         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
56     EXPECT_STREQ(error.what(),
57                  "PMBusError: VOUT_MODE contains unsupported data format");
58 }
59