diff --git a/tests/inflate_test.cpp b/tests/inflate_test.cpp index 9b69af07ef7e0028daaaa9de896380bd850cb1c3..df3d7ea97783fd9e5933cbcc817f07c5105be802 100644 --- a/tests/inflate_test.cpp +++ b/tests/inflate_test.cpp @@ -198,12 +198,27 @@ TEST (HuffmanTests, TestReadChunkFixed) { ASSERT_EQ (read_chunk((char *) buf, HUFFMAN_FIXED), i); } + + /* Test reading all possible fixed distances */ - // TODO test fixed distance codes as well? -} + /* + * Mapping of distance literal -> code, again, as laid out in memory. + */ + int codes_dist[30] = {0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, + 14, 30, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, + 27, 7, 23}; + + for (int i = 0; i < 30; i++) { + reset_pos(); -// TODO -TEST (HuffmanTests, TestReadLens) {} + int code = codes_dist[i]; + unsigned char buf[1]; + + buf[0] = code; + ASSERT_EQ (read_chunk((char *) buf, HUFFMAN_FIXED_DISTS), i); + } + +} int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv);