1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:07:44 +00:00

AK: Remove OutputMemoryStream for DuplexMemoryStream.

OutputMemoryStream was originally a proxy for DuplexMemoryStream that
did not expose any reading API.

Now I need to add another class that is like OutputMemoryStream but only
for static buffers. My first idea was to make OutputMemoryStream do that
too, but I think it's much better to have a distinct class for that.

I originally wanted to call that class FixedOutputMemoryStream but that
name is really cumbersome and it's a bit unintuitive because
InputMemoryStream is already reading from a fixed buffer.

So let's just use DuplexMemoryStream instead of OutputMemoryStream for
any dynamic stuff and create a new OutputMemoryStream for static
buffers.
This commit is contained in:
asynts 2020-09-15 11:48:54 +02:00 committed by Andreas Kling
parent c9a3a5b488
commit f18e927827
6 changed files with 10 additions and 28 deletions

View file

@ -129,17 +129,17 @@ TEST_CASE(duplex_large_buffer)
Array<u8, 1024> one_kibibyte;
EXPECT_EQ(stream.remaining(), 0ul);
EXPECT_EQ(stream.size(), 0ul);
for (size_t idx = 0; idx < 256; ++idx)
stream << one_kibibyte;
EXPECT_EQ(stream.remaining(), 256 * 1024ul);
EXPECT_EQ(stream.size(), 256 * 1024ul);
for (size_t idx = 0; idx < 128; ++idx)
stream >> one_kibibyte;
EXPECT_EQ(stream.remaining(), 128 * 1024ul);
EXPECT_EQ(stream.size(), 128 * 1024ul);
for (size_t idx = 0; idx < 128; ++idx)
stream >> one_kibibyte;
@ -164,7 +164,7 @@ TEST_CASE(write_endian_values)
{
const u8 expected[] { 4, 3, 2, 1, 1, 2, 3, 4 };
OutputMemoryStream stream;
DuplexMemoryStream stream;
stream << LittleEndian<u32> { 0x01020304 } << BigEndian<u32> { 0x01020304 };
EXPECT_EQ(stream.size(), 8u);