blob: bce785577475f6cce2fee8872bd889bc9c0b58b8 [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 "write_verification_error.hpp"
17
18#include <gtest/gtest.h>
19
20using namespace phosphor::power::regulators;
21
22TEST(WriteVerificationErrorTests, Constructor)
23{
Shawn McCarney36fc2612021-03-16 15:44:26 -050024 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");
Shawn McCarneya5ef5402020-03-01 16:29:44 -060031 EXPECT_STREQ(error.what(),
32 "WriteVerificationError: device: vdd1, register: 0x21, "
33 "value_written: 0xAD, value_read: 0x00");
34}
35
Shawn McCarney36fc2612021-03-16 15:44:26 -050036TEST(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
45TEST(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
Shawn McCarneya5ef5402020-03-01 16:29:44 -060055TEST(WriteVerificationErrorTests, What)
56{
Shawn McCarney36fc2612021-03-16 15:44:26 -050057 WriteVerificationError error(
58 "device: vdd1, register: 0x21, value_written: 0xAD, value_read: 0x00",
59 "vdd1",
60 "/xyz/openbmc_project/inventory/system/chassis/motherboard/reg2");
Shawn McCarneya5ef5402020-03-01 16:29:44 -060061 EXPECT_STREQ(error.what(),
Shawn McCarney36fc2612021-03-16 15:44:26 -050062 "WriteVerificationError: device: vdd1, register: 0x21, "
63 "value_written: 0xAD, value_read: 0x00");
Shawn McCarneya5ef5402020-03-01 16:29:44 -060064}