mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
This compression scheme was quite popular during the 80's, and we can still find it in use inside file formats such as TIFF or PDF.
26 lines
694 B
C++
26 lines
694 B
C++
/*
|
|
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibTest/TestCase.h>
|
|
|
|
#include <AK/Array.h>
|
|
#include <LibCompress/PackBitsDecoder.h>
|
|
|
|
TEST_CASE(pack_bits)
|
|
{
|
|
Array<u8, 15> const compressed {
|
|
0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA
|
|
};
|
|
|
|
Array<u8, 24> const raw {
|
|
0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00,
|
|
0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA
|
|
};
|
|
|
|
auto unpacked = TRY_OR_FAIL(Compress::PackBits::decode_all(compressed));
|
|
EXPECT_EQ(unpacked.bytes(), raw);
|
|
}
|