ladybird/Tests/LibCompress/TestPackBits.cpp
Lucas CHOLLET d748edd994 LibCompress: Add a PackBits decoder
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.
2023-12-27 17:40:11 +01:00

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);
}