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