24 #include "ns3/bit-serializer.h"
25 #include "ns3/bit-deserializer.h"
38 virtual void DoRun (
void);
50 testBitSerializer1.
PushBits (0x55, 7);
51 testBitSerializer1.
PushBits (0x7, 3);
52 testBitSerializer1.
PushBits (0x0, 2);
56 "Incorrect serialization " << std::hex << +
result[0] << +
result[1] <<
" instead of " << 0xab <<
" " << 0xc0 << std::dec);
60 testBitSerializer2.
PushBits (0x55, 7);
61 testBitSerializer2.
PushBits (0x7, 3);
62 testBitSerializer2.
PushBits (0x0, 2);
68 "Incorrect serialization " << std::hex << +
result[0] << +
result[1] <<
" instead of " << 0x0a <<
" " << 0xbc << std::dec);
80 virtual void DoRun (
void);
100 testBitDeserializer1.
PushBytes (test1, 2);
101 nibble1 = testBitDeserializer1.
GetBits (7);
102 nibble2 = testBitDeserializer1.
GetBits (3);
103 nibble3 = testBitDeserializer1.
GetBits (2);
104 result = (nibble1 == 0x55) && (nibble2 == 0x7) && (nibble3 == 0x0);
107 "Incorrect deserialization " << std::hex << nibble1 <<
" " << nibble2 <<
" " << nibble3 <<
108 " << instead of " <<
" " << 0x55 <<
" " << 0x7 <<
" " << 0x0 << std::dec);
111 std::vector<uint8_t> test2;
112 test2.push_back (0xab);
113 test2.push_back (0xc0);
116 nibble1 = testBitDeserializer2.
GetBits (7);
117 nibble2 = testBitDeserializer2.
GetBits (3);
118 nibble3 = testBitDeserializer2.
GetBits (2);
120 result = (nibble1 == 0x55) && (nibble2 == 0x7) && (nibble3 == 0x0);
123 "Incorrect deserialization " << std::hex << nibble1 <<
" " << nibble2 <<
" " << nibble3 <<
124 " << instead of " <<
" " << 0x55 <<
" " << 0x7 <<
" " << 0x0 << std::dec);
static BitSerializerTestSuite g_bitSerializerTest
Static variable for test initialization.
Bit deserialization test.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
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.