19 #include "ns3/bit-deserializer.h"
20 #include "ns3/bit-serializer.h"
38 void DoRun()
override;
52 testBitSerializer1.
PushBits(0x55, 7);
56 std::vector<uint8_t> result = testBitSerializer1.
GetBytes();
59 "Incorrect serialization " << std::hex << +result[0] << +result[1]
60 <<
" instead of " << 0xab <<
" " << 0xc0
65 testBitSerializer2.
PushBits(0x55, 7);
71 result = testBitSerializer2.
GetBytes();
74 "Incorrect serialization " << std::hex << +result[0] << +result[1]
75 <<
" instead of " << 0x0a <<
" " << 0xbc
88 void DoRun()
override;
110 testBitDeserializer1.
PushBytes(test1, 2);
111 nibble1 = testBitDeserializer1.
GetBits(7);
112 nibble2 = testBitDeserializer1.
GetBits(3);
113 nibble3 = testBitDeserializer1.
GetBits(2);
114 result = (nibble1 == 0x55) && (nibble2 == 0x7) && (nibble3 == 0x0);
118 "Incorrect deserialization " << std::hex << nibble1 <<
" " << nibble2
119 <<
" " << nibble3 <<
" << instead of "
120 <<
" " << 0x55 <<
" " << 0x7 <<
" " << 0x0
124 std::vector<uint8_t> test2;
125 test2.push_back(0xab);
126 test2.push_back(0xc0);
129 nibble1 = testBitDeserializer2.
GetBits(7);
130 nibble2 = testBitDeserializer2.
GetBits(3);
131 nibble3 = testBitDeserializer2.
GetBits(2);
133 result = (nibble1 == 0x55) && (nibble2 == 0x7) && (nibble3 == 0x0);
137 "Incorrect deserialization " << std::hex << nibble1 <<
" " << nibble2
138 <<
" " << nibble3 <<
" << instead of "
139 <<
" " << 0x55 <<
" " << 0x7 <<
" " << 0x0
static BitSerializerTestSuite g_bitSerializerTest
Static variable for test initialization.
Bit deserialization test.
void DoRun() override
Implementation to actually run this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
Packet Metadata TestSuite.
void PushBytes(std::vector< uint8_t > bytes)
Pushes some bytes into the blob to be deserialized.
uint64_t GetBits(uint8_t size)
Pops a given number of bits from the blob front.
void PushBits(uint64_t value, uint8_t significantBits)
Pushes a number of bits in the blob.
std::vector< uint8_t > GetBytes()
Get the bytes representation of the blob.
void InsertPaddingAtEnd(bool padAtEnd)
Toggles the padding insertion policy.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.