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 "write_verification_error.hpp"
17 
18 #include <gtest/gtest.h>
19 
20 using namespace phosphor::power::regulators;
21 
TEST(WriteVerificationErrorTests,Constructor)22 TEST(WriteVerificationErrorTests, Constructor)
23 {
24     WriteVerificationError error(
25         "device: vdd1, register: 0x21, value_written: 0xAD, value_read: 0x00",
26         "vdd1",
27         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
28     EXPECT_EQ(error.getDeviceID(), "vdd1");
29     EXPECT_EQ(error.getInventoryPath(),
30               "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
31     EXPECT_STREQ(error.what(),
32                  "WriteVerificationError: device: vdd1, register: 0x21, "
33                  "value_written: 0xAD, value_read: 0x00");
34 }
35 
TEST(WriteVerificationErrorTests,GetDeviceID)36 TEST(WriteVerificationErrorTests, GetDeviceID)
37 {
38     WriteVerificationError error(
39         "device: vdd1, register: 0x21, value_written: 0xAD, value_read: 0x00",
40         "vdd1",
41         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
42     EXPECT_EQ(error.getDeviceID(), "vdd1");
43 }
44 
TEST(WriteVerificationErrorTests,GetInventoryPath)45 TEST(WriteVerificationErrorTests, GetInventoryPath)
46 {
47     WriteVerificationError error(
48         "device: vdd1, register: 0x21, value_written: 0xAD, value_read: 0x00",
49         "vdd1",
50         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
51     EXPECT_EQ(error.getInventoryPath(),
52               "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
53 }
54 
TEST(WriteVerificationErrorTests,What)55 TEST(WriteVerificationErrorTests, What)
56 {
57     WriteVerificationError error(
58         "device: vdd1, register: 0x21, value_written: 0xAD, value_read: 0x00",
59         "vdd1",
60         "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
61     EXPECT_STREQ(error.what(),
62                  "WriteVerificationError: device: vdd1, register: 0x21, "
63                  "value_written: 0xAD, value_read: 0x00");
64 }
65