1 #include <gpioplus/utility/aspeed.hpp>
2
3 #include <gtest/gtest.h>
4
5 namespace gpioplus
6 {
7 namespace utility
8 {
9 namespace aspeed
10 {
11 namespace
12 {
13
TEST(AspeedTest,NameToOffset)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
TEST(AspeedTest,NameToOffsetShort)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
TEST(AspeedTest,NameToOffsetBad)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
TEST(AspeedTest,NameToOffsetMaybeBad)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
48