mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 00:09:44 +00:00
LibCompress: Don't assume zlib header is available right away
Instead of checking the header in ZlibDecompressor::create(), we now check it in read_some() when it is called for the first time. This resolves a FIXME in the new DecompressionStream implementation.
This commit is contained in:
parent
be09893fa7
commit
135daeb8bb
Notes:
github-actions[bot]
2024-11-19 00:56:46 +00:00
Author: https://github.com/vkoskiv
Commit: 135daeb8bb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2427
Reviewed-by: https://github.com/trflynn89 ✅
6 changed files with 45 additions and 24 deletions
|
@ -27,6 +27,25 @@ TEST_CASE(zlib_decompress_simple)
|
|||
EXPECT(decompressed.bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 }));
|
||||
}
|
||||
|
||||
TEST_CASE(zlib_decompress_stream)
|
||||
{
|
||||
Array<u8, 40> const compressed {
|
||||
0x78, 0x01, 0x01, 0x1D, 0x00, 0xE2, 0xFF, 0x54, 0x68, 0x69, 0x73, 0x20,
|
||||
0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20,
|
||||
0x74, 0x65, 0x78, 0x74, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x3A, 0x29,
|
||||
0x99, 0x5E, 0x09, 0xE8
|
||||
};
|
||||
|
||||
u8 const uncompressed[] = "This is a simple text file :)";
|
||||
|
||||
auto stream = make<AllocatingMemoryStream>();
|
||||
auto input = MaybeOwned<Stream> { *stream };
|
||||
auto decompressor = TRY_OR_FAIL(Compress::ZlibDecompressor::create(move(input)));
|
||||
TRY_OR_FAIL(stream->write_until_depleted(compressed));
|
||||
auto decompressed = TRY_OR_FAIL(decompressor->read_until_eof());
|
||||
EXPECT(decompressed.bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 }));
|
||||
}
|
||||
|
||||
TEST_CASE(zlib_compress_simple)
|
||||
{
|
||||
// Note: This is just the output of our compression function from an arbitrary point in time.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue