mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:37:46 +00:00
LibCompress: Simplify logic in deflate implementation.
This commit is contained in:
parent
6de63782c7
commit
4c317a94c7
2 changed files with 36 additions and 9 deletions
|
@ -64,9 +64,8 @@ TEST_CASE(overwritting_is_well_defined)
|
|||
|
||||
stream >> Bytes { bytes, sizeof(bytes) };
|
||||
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx) {
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx)
|
||||
EXPECT_EQ(bytes[idx], idx % 256);
|
||||
}
|
||||
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx)
|
||||
stream << static_cast<u8>(idx % 256);
|
||||
|
@ -84,4 +83,31 @@ TEST_CASE(overwritting_is_well_defined)
|
|||
EXPECT(stream.eof());
|
||||
}
|
||||
|
||||
TEST_CASE(of_by_one)
|
||||
{
|
||||
constexpr size_t half_capacity = 32;
|
||||
constexpr size_t capacity = half_capacity * 2;
|
||||
|
||||
CircularDuplexStream<capacity> stream;
|
||||
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx)
|
||||
stream << static_cast<u8>(0);
|
||||
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx)
|
||||
stream << static_cast<u8>(1);
|
||||
|
||||
stream.discard_or_error(capacity);
|
||||
|
||||
for (size_t idx = 0; idx < capacity; ++idx) {
|
||||
u8 byte;
|
||||
stream.read({ &byte, sizeof(byte) }, capacity);
|
||||
stream << byte;
|
||||
|
||||
if (idx < half_capacity)
|
||||
EXPECT_EQ(byte, 0);
|
||||
else
|
||||
EXPECT_EQ(byte, 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_MAIN(CircularDuplexStream)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue