Skip to content

Commit

Permalink
tests: unittest: MemoryOutputStream_1.test: added testcases for write…
Browse files Browse the repository at this point in the history
…ByteRepeatedly()
  • Loading branch information
ZoltanBojthe committed Jul 14, 2023
1 parent e84ce92 commit a3b22b2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/unit/MemoryOutputStream_1.test
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
//

Expand All @@ -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";

Expand All @@ -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);
.

0 comments on commit a3b22b2

Please sign in to comment.