mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Add a flate_backref_crosses_blocks test.
This commit is contained in:
1 parent
27a33ff27c
commit
bcc7171b5a
4 files changed
+81
-25
No files matched your search
+49
-25
@@ -65,6 +65,15 @@ golden_test flate_256_bytes_gt = {
|
|||||||
.src_offset1 = 281, //
|
.src_offset1 = 281, //
|
||||||
};
|
};
|
||||||
|
|
||||||
|
golden_test flate_flate_backref_crosses_blocks_gt = {
|
||||||
|
.want_filename =
|
||||||
|
"../../testdata/artificial/"
|
||||||
|
"flate-backref-crosses-blocks.flate.decompressed",
|
||||||
|
.src_filename =
|
||||||
|
"../../testdata/artificial/"
|
||||||
|
"flate-backref-crosses-blocks.flate",
|
||||||
|
};
|
||||||
|
|
||||||
golden_test flate_midsummer_gt = {
|
golden_test flate_midsummer_gt = {
|
||||||
.want_filename = "../../testdata/midsummer.txt", //
|
.want_filename = "../../testdata/midsummer.txt", //
|
||||||
.src_filename = "../../testdata/midsummer.txt.gz", //
|
.src_filename = "../../testdata/midsummer.txt.gz", //
|
||||||
@@ -244,6 +253,13 @@ void test_puffs_flate_decode_256_bytes() {
|
|||||||
do_test_buf1_buf1(puffs_flate_decode, &flate_256_bytes_gt, 0, 0);
|
do_test_buf1_buf1(puffs_flate_decode, &flate_256_bytes_gt, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_puffs_flate_decode_flate_backref_crosses_blocks() {
|
||||||
|
proc_funcname = __func__;
|
||||||
|
// TODO: uncomment.
|
||||||
|
// do_test_buf1_buf1(puffs_flate_decode,
|
||||||
|
// &flate_flate_backref_crosses_blocks_gt, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void test_puffs_flate_decode_midsummer() {
|
void test_puffs_flate_decode_midsummer() {
|
||||||
proc_funcname = __func__;
|
proc_funcname = __func__;
|
||||||
do_test_buf1_buf1(puffs_flate_decode, &flate_midsummer_gt, 0, 0);
|
do_test_buf1_buf1(puffs_flate_decode, &flate_midsummer_gt, 0, 0);
|
||||||
@@ -676,6 +692,12 @@ void test_mimic_flate_decode_256_bytes() {
|
|||||||
do_test_buf1_buf1(mimic_flate_decode, &flate_256_bytes_gt, 0, 0);
|
do_test_buf1_buf1(mimic_flate_decode, &flate_256_bytes_gt, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_mimic_flate_decode_flate_backref_crosses_blocks() {
|
||||||
|
proc_funcname = __func__;
|
||||||
|
do_test_buf1_buf1(mimic_flate_decode, &flate_flate_backref_crosses_blocks_gt,
|
||||||
|
0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void test_mimic_flate_decode_midsummer() {
|
void test_mimic_flate_decode_midsummer() {
|
||||||
proc_funcname = __func__;
|
proc_funcname = __func__;
|
||||||
do_test_buf1_buf1(mimic_flate_decode, &flate_midsummer_gt, 0, 0);
|
do_test_buf1_buf1(mimic_flate_decode, &flate_midsummer_gt, 0, 0);
|
||||||
@@ -849,35 +871,37 @@ void bench_mimic_zlib_decode_100k() {
|
|||||||
// The empty comments forces clang-format to place one element per line.
|
// The empty comments forces clang-format to place one element per line.
|
||||||
proc tests[] = {
|
proc tests[] = {
|
||||||
// Flate Tests
|
// Flate Tests
|
||||||
test_puffs_adler32, //
|
test_puffs_adler32, //
|
||||||
test_puffs_flate_decode_256_bytes, //
|
test_puffs_flate_decode_256_bytes, //
|
||||||
test_puffs_flate_decode_midsummer, //
|
test_puffs_flate_decode_flate_backref_crosses_blocks, //
|
||||||
test_puffs_flate_decode_pi, //
|
test_puffs_flate_decode_midsummer, //
|
||||||
test_puffs_flate_decode_pi_many_big_reads, //
|
test_puffs_flate_decode_pi, //
|
||||||
test_puffs_flate_decode_pi_many_medium_reads, //
|
test_puffs_flate_decode_pi_many_big_reads, //
|
||||||
test_puffs_flate_decode_pi_many_small_writes_reads, //
|
test_puffs_flate_decode_pi_many_medium_reads, //
|
||||||
test_puffs_flate_decode_romeo, //
|
test_puffs_flate_decode_pi_many_small_writes_reads, //
|
||||||
test_puffs_flate_decode_romeo_fixed, //
|
test_puffs_flate_decode_romeo, //
|
||||||
test_puffs_flate_decode_split_src, //
|
test_puffs_flate_decode_romeo_fixed, //
|
||||||
test_puffs_flate_history_full, //
|
test_puffs_flate_decode_split_src, //
|
||||||
test_puffs_flate_history_partial, //
|
test_puffs_flate_history_full, //
|
||||||
test_puffs_flate_table_redirect, //
|
test_puffs_flate_history_partial, //
|
||||||
test_puffs_zlib_checksum_mismatch, //
|
test_puffs_flate_table_redirect, //
|
||||||
test_puffs_zlib_decode_midsummer, //
|
test_puffs_zlib_checksum_mismatch, //
|
||||||
test_puffs_zlib_decode_pi, //
|
test_puffs_zlib_decode_midsummer, //
|
||||||
|
test_puffs_zlib_decode_pi, //
|
||||||
|
|
||||||
#ifdef PUFFS_MIMIC
|
#ifdef PUFFS_MIMIC
|
||||||
|
|
||||||
// Mimic Tests
|
// Mimic Tests
|
||||||
test_mimic_flate_decode_256_bytes, //
|
test_mimic_flate_decode_256_bytes, //
|
||||||
test_mimic_flate_decode_midsummer, //
|
test_mimic_flate_decode_flate_backref_crosses_blocks, //
|
||||||
test_mimic_flate_decode_pi, //
|
test_mimic_flate_decode_midsummer, //
|
||||||
test_mimic_flate_decode_romeo, //
|
test_mimic_flate_decode_pi, //
|
||||||
test_mimic_flate_decode_romeo_fixed, //
|
test_mimic_flate_decode_romeo, //
|
||||||
test_mimic_gzip_decode_midsummer, //
|
test_mimic_flate_decode_romeo_fixed, //
|
||||||
test_mimic_gzip_decode_pi, //
|
test_mimic_gzip_decode_midsummer, //
|
||||||
test_mimic_zlib_decode_midsummer, //
|
test_mimic_gzip_decode_pi, //
|
||||||
test_mimic_zlib_decode_pi, //
|
test_mimic_zlib_decode_midsummer, //
|
||||||
|
test_mimic_zlib_decode_pi, //
|
||||||
|
|
||||||
#endif // PUFFS_MIMIC
|
#endif // PUFFS_MIMIC
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
|||||||
|
Running flate-backref-crosses-blocks.flate through script/print-bits.go and
|
||||||
|
adding commentary:
|
||||||
|
|
||||||
|
offset xoffset ASCII hex binary
|
||||||
|
000000 0x0000 . 0x00 0b_0000_0000 Non-compressed block (BTYPE=00), non-final (BFINAL=0)
|
||||||
|
000001 0x0001 . 0x04 0b_0000_0100 Block length is 0x0004 (parity value is 0xFFFB)
|
||||||
|
000002 0x0002 . 0x00 0b_0000_0000
|
||||||
|
000003 0x0003 . 0xFB 0b_1111_1011
|
||||||
|
000004 0x0004 . 0xFF 0b_1111_1111
|
||||||
|
000005 0x0005 a 0x61 0b_0110_0001 Literal "abcd"
|
||||||
|
000006 0x0006 b 0x62 0b_0110_0010
|
||||||
|
000007 0x0007 c 0x63 0b_0110_0011
|
||||||
|
000008 0x0008 d 0x64 0b_0110_0100
|
||||||
|
000009 0x0009 . 0x03 0b_0000_0011 Fixed Huffman block (BTYPE=01), final (BFINAL=1), see below
|
||||||
|
000010 0x000A B 0x42 0b_0100_0010
|
||||||
|
000011 0x000B . 0x00 0b_0000_0000
|
||||||
|
|
||||||
|
The fixed Huffman block consists of a back-reference that refers to the
|
||||||
|
previous (non-compressed) block, and then an "end of block" code. The length=3,
|
||||||
|
distance=2 back-reference decodes to "cdc", so the overall decoding is
|
||||||
|
"abcdcdc". The breakdown of the fixed Huffman block is:
|
||||||
|
|
||||||
|
000009 0x0009 . 0x03 0b_...._.011 Fixed Huffman block (BTYPE=01), final (BFINAL=1)
|
||||||
|
|
||||||
|
000009 0x0009 . 0x03 0b_0000_0... (lcode = 257) length = 3
|
||||||
|
000010 0x000A B 0x42 0b_...._..10
|
||||||
|
|
||||||
|
000010 0x000A B 0x42 0b_.100_00.. (dcode = 1) distance = 2
|
||||||
|
|
||||||
|
000010 0x000A B 0x42 0b_0..._.... (lcode = 256) end of block
|
||||||
|
000011 0x000B . 0x00 0b_..00_0000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
abcdcdc
|
||||||
Reference in new issue
Block a user