Shawn McCarney | a5ef540 | 2020-03-01 16:29:44 -0600 | [diff] [blame] | 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 | |
| 22 | TEST(PMBusErrorTests, Constructor) |
| 23 | { |
Shawn McCarney | 5b819f4 | 2021-03-16 14:41:15 -0500 | [diff] [blame] | 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"); |
Shawn McCarney | a5ef540 | 2020-03-01 16:29:44 -0600 | [diff] [blame] | 30 | EXPECT_STREQ(error.what(), |
| 31 | "PMBusError: VOUT_MODE contains unsupported data format"); |
| 32 | } |
| 33 | |
Shawn McCarney | 5b819f4 | 2021-03-16 14:41:15 -0500 | [diff] [blame] | 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 | |
| 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 | |
Shawn McCarney | a5ef540 | 2020-03-01 16:29:44 -0600 | [diff] [blame] | 51 | TEST(PMBusErrorTests, What) |
| 52 | { |
Shawn McCarney | 5b819f4 | 2021-03-16 14:41:15 -0500 | [diff] [blame] | 53 | PMBusError error( |
| 54 | "VOUT_MODE contains unsupported data format", "vdd_reg", |
| 55 | "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2"); |
Shawn McCarney | a5ef540 | 2020-03-01 16:29:44 -0600 | [diff] [blame] | 56 | EXPECT_STREQ(error.what(), |
Shawn McCarney | 5b819f4 | 2021-03-16 14:41:15 -0500 | [diff] [blame] | 57 | "PMBusError: VOUT_MODE contains unsupported data format"); |
Shawn McCarney | a5ef540 | 2020-03-01 16:29:44 -0600 | [diff] [blame] | 58 | } |