ladybird/Tests/LibCompress/CMakeLists.txt
Idan Horowitz b749167506 LibCompress: Fix off-by-one error in generate_huffman_lengths
Previously we would calculate the index of the first parent node as
heap.size() (which is initialized to non_zero_freqs), so in the edge
case in which all symbols had a non-zero frequency, we would use the
Size-index entry in the array for both the first symbol's leaf node,
and the first parent node.

The result would either be a non-optimal huffman code (bad), or an
illegal huffman code that would then go on to crash due to an error
check in CanonicalCode::from_bytes. (worse)

We now store parent nodes starting at heap.size() - 1, which eliminates
the potential overlap, and resolves the issue.
2023-12-04 00:06:38 +01:00

16 lines
380 B
CMake

set(TEST_SOURCES
TestBrotli.cpp
TestDeflate.cpp
TestGzip.cpp
TestLzma.cpp
TestXz.cpp
TestZlib.cpp
)
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibCompress LIBS LibCompress)
endforeach()
install(DIRECTORY brotli-test-files DESTINATION usr/Tests/LibCompress)
install(DIRECTORY deflate-test-files DESTINATION usr/Tests/LibCompress)