blob: 3e455bac53dd835132e32f30b47a1588b2a4c87a [file] [log] [blame]
Shawn McCarneya5ef5402020-03-01 16:29:44 -06001/**
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
20using namespace phosphor::power::regulators;
21
22TEST(PMBusErrorTests, Constructor)
23{
Shawn McCarney5b819f42021-03-16 14:41:15 -050024 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");
Shawn McCarneya5ef5402020-03-01 16:29:44 -060030 EXPECT_STREQ(error.what(),
31 "PMBusError: VOUT_MODE contains unsupported data format");
32}
33
Shawn McCarney5b819f42021-03-16 14:41:15 -050034TEST(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
42TEST(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
Shawn McCarneya5ef5402020-03-01 16:29:44 -060051TEST(PMBusErrorTests, What)
52{
Shawn McCarney5b819f42021-03-16 14:41:15 -050053 PMBusError error(
54 "VOUT_MODE contains unsupported data format", "vdd_reg",
55 "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
Shawn McCarneya5ef5402020-03-01 16:29:44 -060056 EXPECT_STREQ(error.what(),
Shawn McCarney5b819f42021-03-16 14:41:15 -050057 "PMBusError: VOUT_MODE contains unsupported data format");
Shawn McCarneya5ef5402020-03-01 16:29:44 -060058}