kasunath | 0aa36d8 | 2022-11-23 14:24:15 -0800 | [diff] [blame^] | 1 | #include "bej_common.h" |
| 2 | |
| 3 | #include <gmock/gmock-matchers.h> |
| 4 | #include <gmock/gmock.h> |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | namespace libbej |
| 8 | { |
| 9 | |
| 10 | TEST(BejCommonTest, BejGetUnsignedIntegerTest) |
| 11 | { |
| 12 | constexpr uint8_t bytes[] = {0xab, 0xcd, 0xef, 0x12, |
| 13 | 0x13, 0x65, 0x23, 0x89}; |
| 14 | EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/1), 0xab); |
| 15 | EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/2), 0xcdab); |
| 16 | EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/5), 0x1312efcdab); |
| 17 | EXPECT_THAT(bejGetUnsignedInteger(bytes, /*numOfBytes=*/8), |
| 18 | 0x8923651312efcdab); |
| 19 | } |
| 20 | |
| 21 | TEST(BejCommonTest, BejGetNnintTest) |
| 22 | { |
| 23 | constexpr uint8_t nnint1[] = {0x03, 0xcd, 0xef, 0x12}; |
| 24 | constexpr uint8_t nnint2[] = {0x08, 0xab, 0xcd, 0xef, 0x12, |
| 25 | 0x13, 0x65, 0x23, 0x89}; |
| 26 | EXPECT_THAT(bejGetNnint(nnint1), 0x12efcd); |
| 27 | EXPECT_THAT(bejGetNnint(nnint2), 0x8923651312efcdab); |
| 28 | } |
| 29 | |
| 30 | TEST(BejCommonTest, BejGetNnintSizeTest) |
| 31 | { |
| 32 | constexpr uint8_t nnint1[] = {0x03, 0xcd, 0xef, 0x12}; |
| 33 | constexpr uint8_t nnint2[] = {0x08, 0xab, 0xcd, 0xef, 0x12, |
| 34 | 0x13, 0x65, 0x23, 0x89}; |
| 35 | EXPECT_THAT(bejGetNnintSize(nnint1), 4); |
| 36 | EXPECT_THAT(bejGetNnintSize(nnint2), 9); |
| 37 | } |
| 38 | |
| 39 | } // namespace libbej |