William A. Kennington III | 8ff5812 | 2018-10-26 00:42:36 -0700 | [diff] [blame] | 1 | #include <gpioplus/utility/aspeed.hpp> |
Patrick Williams | 7ba248a | 2023-05-10 07:51:30 -0500 | [diff] [blame] | 2 | |
William A. Kennington III | 8ff5812 | 2018-10-26 00:42:36 -0700 | [diff] [blame] | 3 | #include <gtest/gtest.h> |
| 4 | |
| 5 | namespace gpioplus |
| 6 | { |
| 7 | namespace utility |
| 8 | { |
| 9 | namespace aspeed |
| 10 | { |
| 11 | namespace |
| 12 | { |
| 13 | |
| 14 | TEST(AspeedTest, NameToOffset) |
| 15 | { |
| 16 | EXPECT_EQ(5, nameToOffset("A5")); |
| 17 | EXPECT_EQ(33, nameToOffset("E1")); |
| 18 | EXPECT_EQ(202, nameToOffset("Z2")); |
| 19 | EXPECT_EQ(208, nameToOffset("AA0")); |
| 20 | EXPECT_EQ(223, nameToOffset("AB7")); |
| 21 | } |
| 22 | |
| 23 | TEST(AspeedTest, NameToOffsetShort) |
| 24 | { |
| 25 | EXPECT_THROW(nameToOffset(""), std::logic_error); |
| 26 | EXPECT_THROW(nameToOffset("A"), std::logic_error); |
| 27 | EXPECT_THROW(nameToOffset("0"), std::logic_error); |
| 28 | } |
| 29 | |
| 30 | TEST(AspeedTest, NameToOffsetBad) |
| 31 | { |
| 32 | EXPECT_THROW(nameToOffset("00"), std::logic_error); |
| 33 | EXPECT_THROW(nameToOffset("AB"), std::logic_error); |
| 34 | EXPECT_THROW(nameToOffset(".1"), std::logic_error); |
| 35 | EXPECT_THROW(nameToOffset("A#"), std::logic_error); |
| 36 | } |
| 37 | |
| 38 | TEST(AspeedTest, NameToOffsetMaybeBad) |
| 39 | { |
| 40 | EXPECT_THROW(nameToOffset("BA0"), std::logic_error); |
| 41 | EXPECT_THROW(nameToOffset("AAA0"), std::logic_error); |
| 42 | } |
| 43 | |
| 44 | } // namespace |
| 45 | } // namespace aspeed |
| 46 | } // namespace utility |
| 47 | } // namespace gpioplus |