#include #include #include using namespace vanetza; using le_type = EndianType; using be_type = EndianType; TEST(ByteOrder, equality) { EndianType a(3); EndianType b(3); EXPECT_EQ(a, b); a = host_cast(static_cast(4)); EXPECT_NE(a, b); } TEST(ByteOrder, access) { le_type a = host_cast(0x12345678); be_type b = host_cast(0x12345678); EXPECT_NE(a.get(), b.get()); EXPECT_EQ(a.net(), b.net()); EXPECT_EQ(a.host(), b.host()); } TEST(ByteOrder, less) { uint8be_t a { 3 }; uint8be_t b { 5 }; uint8be_t c { 5 }; EXPECT_TRUE(a < b); EXPECT_FALSE(b < c); EXPECT_FALSE(b < a); } TEST(ByteOrder, hash) { le_type a = host_cast(0x12345678); be_type b = host_cast(0x12345678); be_type c = host_cast(0x78563412); EXPECT_EQ(std::hash()(a), std::hash()(a)); EXPECT_EQ(std::hash()(b), std::hash()(b)); EXPECT_NE(std::hash()(b), std::hash()(c)); }