MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / test_writes

Function test_writes

tests/bytes.cc:81–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81static void test_writes()
82{
83 Bytes b;
84 ByteWriter bw(b);
85
86 bw.seek(0);
87 bw.write_8(1);
88 assert((b == Bytes{1}));
89 bw.write_be32(0x02020202);
90 assert((b == Bytes{1, 2, 2, 2, 2}));
91
92 auto reset = [&]()
93 {
94 b.resize(0);
95 bw.seek(0);
96 };
97
98 // clang-format off
99 reset(); bw.write_le16(0x0102); assert((b == Bytes{2, 1}));
100 reset(); bw.write_be16(0x0102); assert((b == Bytes{1, 2}));
101 reset(); bw.write_le24(0x010203); assert((b == Bytes{3, 2, 1}));
102 reset(); bw.write_be24(0x010203); assert((b == Bytes{1, 2, 3}));
103 reset(); bw.write_le32(0x01020304); assert((b == Bytes{4, 3, 2, 1}));
104 reset(); bw.write_be32(0x01020304); assert((b == Bytes{1, 2, 3, 4}));
105 // clang-format on
106
107 reset();
108 bw += {1, 2, 3, 4, 5};
109 assert((b == Bytes{1, 2, 3, 4, 5}));
110}
111
112static void test_slice()
113{

Callers 1

mainFunction · 0.85

Calls 2

seekMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected