blob: 3217ffd718e8f81917814c362c48d953e84b2c04 [file] [log] [blame]
kasunath7ffd30a2022-05-10 18:11:34 -07001#include "rde_common.h"
2
3#include <gmock/gmock-matchers.h>
4#include <gmock/gmock.h>
5#include <gtest/gtest.h>
6
7namespace rde
8{
9
10TEST(RdeCommonTest, RdeGetUnsignedIntegerTest)
11{
12 constexpr uint8_t bytes[] = {0xab, 0xcd, 0xef, 0x12,
13 0x13, 0x65, 0x23, 0x89};
14 EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/1), 0xab);
15 EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/2), 0xcdab);
16 EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/5), 0x1312efcdab);
17 EXPECT_THAT(rdeGetUnsignedInteger(bytes, /*numOfBytes=*/8),
18 0x8923651312efcdab);
19}
20
21TEST(RdeCommonTest, RdeGetNnintTest)
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(rdeGetNnint(nnint1), 0x12efcd);
27 EXPECT_THAT(rdeGetNnint(nnint2), 0x8923651312efcdab);
28}
29
30TEST(RdeCommonTest, RdeGetNnintSizeTest)
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(rdeGetNnintSize(nnint1), 4);
36 EXPECT_THAT(rdeGetNnintSize(nnint2), 9);
37}
38
39} // namespace rde