ladybird/Tests/LibCompress/TestPackBits.cpp

26 lines
694 B
C++
Raw Normal View History

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