blob: 562ea69454d0cc6004c757290f7ec8511606012f [file] [log] [blame]
William A. Kennington III8ff58122018-10-26 00:42:36 -07001#include <gpioplus/utility/aspeed.hpp>
Patrick Williams7ba248a2023-05-10 07:51:30 -05002
William A. Kennington III8ff58122018-10-26 00:42:36 -07003#include <gtest/gtest.h>
4
5namespace gpioplus
6{
7namespace utility
8{
9namespace aspeed
10{
11namespace
12{
13
14TEST(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
23TEST(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
30TEST(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
38TEST(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