diff --git a/tests/unit/MemoryOutputStream_1.test b/tests/unit/MemoryOutputStream_1.test index 45ae70e8352..90ef5ebfc63 100644 --- a/tests/unit/MemoryOutputStream_1.test +++ b/tests/unit/MemoryOutputStream_1.test @@ -22,6 +22,7 @@ static std::ostream& operator<<(std::ostream& os, const ::inet::MemoryOutputStre #define Bit(x) s.writeBit(x) #define BitR(x, y) s.writeBitRepeatedly(x, y) #define Byte(x) s.writeByte(x) +#define ByteR(x, y) s.writeByteRepeatedly(x, y) #define TEST(x, y, z) { inet::MemoryOutputStream s; x; EV << " TEST(" << #x << ", " << #y << ", " << s << ");\n"; } // @@ -42,6 +43,17 @@ static std::ostream& operator<<(std::ostream& os, const ::inet::MemoryOutputStre TEST(BitR(1,3);Byte(0x82);BitR(1,5), 111 1000.0010 1111.1: 1111 0000 0101 1111, f0 5f); TEST(BitR(0,7);Byte(0x82);Bit(0), 0000.000 1000.0010 0: 0000 0001 0000 0100, 01 04); TEST(BitR(1,7);Byte(0x82);Bit(1), 1111.111 1000.0010 1: 1111 1111 0000 0101, ff 05); + TEST(Bit(0);ByteR(0xff,3);BitR(0,7), 0 1111.1111 1111.1111 1111.1111 0000.000: 0111 1111 1111 1111 1111 1111 1000 0000, 7f ff ff 80); + TEST(Bit(1);ByteR(0x00,3);BitR(1,7), 1 0000.0000 0000.0000 0000.0000 1111.111: 1000 0000 0000 0000 0000 0000 0111 1111, 80 00 00 7f); + TEST(Bit(1);ByteR(0xff,3);BitR(1,7), 1 1111.1111 1111.1111 1111.1111 1111.111: 1111 1111 1111 1111 1111 1111 1111 1111, ff ff ff ff); + TEST(Bit(0);ByteR(0x82,3);BitR(0,7), 0 1000.0010 1000.0010 1000.0010 0000.000: 0100 0001 0100 0001 0100 0001 0000 0000, 41 41 41 00); + TEST(Bit(1);ByteR(0x82,3);BitR(1,7), 1 1000.0010 1000.0010 1000.0010 1111.111: 1100 0001 0100 0001 0100 0001 0111 1111, c1 41 41 7f); + TEST(BitR(0,5);ByteR(0x82,3);BitR(0,3), 0000.0 1000.0010 1000.0010 1000.0010 000: 0000 0100 0001 0100 0001 0100 0001 0000, 04 14 14 10); + TEST(BitR(1,5);ByteR(0x82,3);BitR(1,3), 1111.1 1000.0010 1000.0010 1000.0010 111: 1111 1100 0001 0100 0001 0100 0001 0111, fc 14 14 17); + TEST(BitR(0,3);ByteR(0x82,3);BitR(0,5), 000 1000.0010 1000.0010 1000.0010 0000.0: 0001 0000 0101 0000 0101 0000 0100 0000, 10 50 50 40); + TEST(BitR(1,3);ByteR(0x82,3);BitR(1,5), 111 1000.0010 1000.0010 1000.0010 1111.1: 1111 0000 0101 0000 0101 0000 0101 1111, f0 50 50 5f); + TEST(BitR(0,7);ByteR(0x82,3);Bit(0), 0000.000 1000.0010 1000.0010 1000.0010 0: 0000 0001 0000 0101 0000 0101 0000 0100, 01 05 05 04); + TEST(BitR(1,7);ByteR(0x82,3);Bit(1), 1111.111 1000.0010 1000.0010 1000.0010 1: 1111 1111 0000 0101 0000 0101 0000 0101, ff 05 05 05); EV << ".\n"; @@ -59,4 +71,15 @@ Start: TEST(BitR(1,3);Byte(0x82);BitR(1,5), 111 1000.0010 1111.1: 1111 0000 0101 1111, f0 5f); TEST(BitR(0,7);Byte(0x82);Bit(0), 0000.000 1000.0010 0: 0000 0001 0000 0100, 01 04); TEST(BitR(1,7);Byte(0x82);Bit(1), 1111.111 1000.0010 1: 1111 1111 0000 0101, ff 05); + TEST(Bit(0);ByteR(0xff,3);BitR(0,7), 0 1111.1111 1111.1111 1111.1111 0000.000: 0111 1111 1111 1111 1111 1111 1000 0000, 7f ff ff 80); + TEST(Bit(1);ByteR(0x00,3);BitR(1,7), 1 0000.0000 0000.0000 0000.0000 1111.111: 1000 0000 0000 0000 0000 0000 0111 1111, 80 00 00 7f); + TEST(Bit(1);ByteR(0xff,3);BitR(1,7), 1 1111.1111 1111.1111 1111.1111 1111.111: 1111 1111 1111 1111 1111 1111 1111 1111, ff ff ff ff); + TEST(Bit(0);ByteR(0x82,3);BitR(0,7), 0 1000.0010 1000.0010 1000.0010 0000.000: 0100 0001 0100 0001 0100 0001 0000 0000, 41 41 41 00); + TEST(Bit(1);ByteR(0x82,3);BitR(1,7), 1 1000.0010 1000.0010 1000.0010 1111.111: 1100 0001 0100 0001 0100 0001 0111 1111, c1 41 41 7f); + TEST(BitR(0,5);ByteR(0x82,3);BitR(0,3), 0000.0 1000.0010 1000.0010 1000.0010 000: 0000 0100 0001 0100 0001 0100 0001 0000, 04 14 14 10); + TEST(BitR(1,5);ByteR(0x82,3);BitR(1,3), 1111.1 1000.0010 1000.0010 1000.0010 111: 1111 1100 0001 0100 0001 0100 0001 0111, fc 14 14 17); + TEST(BitR(0,3);ByteR(0x82,3);BitR(0,5), 000 1000.0010 1000.0010 1000.0010 0000.0: 0001 0000 0101 0000 0101 0000 0100 0000, 10 50 50 40); + TEST(BitR(1,3);ByteR(0x82,3);BitR(1,5), 111 1000.0010 1000.0010 1000.0010 1111.1: 1111 0000 0101 0000 0101 0000 0101 1111, f0 50 50 5f); + TEST(BitR(0,7);ByteR(0x82,3);Bit(0), 0000.000 1000.0010 1000.0010 1000.0010 0: 0000 0001 0000 0101 0000 0101 0000 0100, 01 05 05 04); + TEST(BitR(1,7);ByteR(0x82,3);Bit(1), 1111.111 1000.0010 1000.0010 1000.0010 1: 1111 1111 0000 0101 0000 0101 0000 0101, ff 05 05 05); .