From f11e1f97c6f59d411216da13be66e97391d8ed12 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 21 Mar 2018 12:32:51 +1100 Subject: [PATCH] Add deflate-distance-32768 test case --- script/make-deflate.go | 426 ++++++++++++++++++ test/c/std/deflate.c | 65 ++- ...kref-crosses-blocks.deflate.commentary.txt | 27 +- ...te-backref-crosses-blocks.deflate.make.txt | 12 + .../artificial/deflate-distance-32768.deflate | Bin 0 -> 252 bytes ...late-distance-32768.deflate.commentary.txt | 52 +++ ...eflate-distance-32768.deflate.decompressed | 1 + .../deflate-distance-32768.deflate.make.txt | 28 ++ 8 files changed, 574 insertions(+), 37 deletions(-) create mode 100644 script/make-deflate.go create mode 100644 test/data/artificial/deflate-backref-crosses-blocks.deflate.make.txt create mode 100644 test/data/artificial/deflate-distance-32768.deflate create mode 100644 test/data/artificial/deflate-distance-32768.deflate.commentary.txt create mode 100644 test/data/artificial/deflate-distance-32768.deflate.decompressed create mode 100644 test/data/artificial/deflate-distance-32768.deflate.make.txt diff --git a/script/make-deflate.go b/script/make-deflate.go new file mode 100644 index 00000000..97816237 --- /dev/null +++ b/script/make-deflate.go @@ -0,0 +1,426 @@ +// Copyright 2018 The Wuffs Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build ignore + +package main + +// make-deflate.go makes some data in the deflate format. +// +// See test/data/artificial/*.deflate.make.txt for examples. +// +// Usage: go run make-deflate.go < foo.make.txt + +import ( + "fmt" + "io/ioutil" + "os" + "strconv" + "strings" +) + +// Global state. +var ( + block uint32 + bncData []byte + repeats []repeat + stream bitStream +) + +const ( + blockZero = 0 + blockNoCompression = 1 + blockFixedHuffman = 2 + // TODO: blockDynamicHuffman. +) + +var doFuncs = [...]func(s string) error{ + blockZero: doBlockZero, + blockNoCompression: doBlockNoCompression, + blockFixedHuffman: doBlockFixedHuffman, +} + +type bitStream struct { + buf []byte + bits uint32 + nBits uint32 // Always within [0, 7]. +} + +// writeBits writes the low n bits of b to z. +func (z *bitStream) writeBits(b uint32, n uint32) { + if n > 24 { + panic("writeBits: n is too large") + } + z.bits |= b << z.nBits + z.nBits += n + for z.nBits >= 8 { + z.buf = append(z.buf, uint8(z.bits)) + z.bits >>= 8 + z.nBits -= 8 + } +} + +func (z *bitStream) writeBytes(b []byte) { + z.flush() + z.buf = append(z.buf, b...) +} + +func (z *bitStream) writeLCode(lCode uint32) { + switch { + case lCode < 144: // 0b._0011_0000 through 0b._1011_1111 + lCode += 0x030 + z.writeBits(reverse(lCode, 8), 8) + case lCode < 256: // 0b1_1001_0000 through 0b1_1111_1111 + lCode += 0x190 - 144 + z.writeBits(reverse(lCode, 9), 9) + case lCode < 280: // 0b._.000_0000 through 0b._.001_0111 + lCode -= 256 - 0x000 + z.writeBits(reverse(lCode, 7), 7) + default: // 0b._1100_0000 through 0b._1100_0111 + lCode -= 280 - 0x0C0 + z.writeBits(reverse(lCode, 8), 8) + } +} + +func (z *bitStream) flush() { + if z.nBits > 0 { + z.buf = append(z.buf, uint8(z.bits)) + z.bits = 0 + z.nBits = 0 + } +} + +type repeat struct { + count uint32 + remaining string +} + +func main() { + if err := main1(); err != nil { + os.Stderr.WriteString(err.Error() + "\n") + os.Exit(1) + } +} + +func main1() error { + stdin, err := ioutil.ReadAll(os.Stdin) + if err != nil { + return err + } + s := string(stdin) + for remaining := ""; len(s) > 0; s, remaining = remaining, "" { + if i := strings.IndexByte(s, '\n'); i >= 0 { + s, remaining = s[:i], s[i+1:] + } + s = strings.TrimSpace(s) + if s == "" || s[0] == '#' { + continue + } + + const rep = "repeat " + if strings.HasPrefix(s, rep) { + args := s[len(rep):] + count, args, ok := parseNum(args) + if !ok || count <= 0 || args != "[" { + return fmt.Errorf("bad repeat command: %q", s) + } + repeats = append(repeats, repeat{ + count: count, + remaining: remaining, + }) + continue + } + + if s == "]" { + if len(repeats) <= 0 { + return fmt.Errorf(`unbalanced close-repeat command: "]"`) + } + i := len(repeats) - 1 + repeats[i].count-- + if repeats[i].count == 0 { + repeats = repeats[:i] + } else { + remaining = repeats[i].remaining + } + continue + } + + if err := doFuncs[block](s); err != nil { + return err + } + } + + stream.flush() + _, err = os.Stdout.Write(stream.buf) + return err +} + +func doBlockZero(line string) error { + const ( + bnc = "blockNoCompression " + bfh = "blockFixedHuffman " + ) + bits := uint32(0) + s := "" + + switch { + case strings.HasPrefix(line, bnc): + s = line[len(bnc):] + block = blockNoCompression + bits |= 0 << 1 + case strings.HasPrefix(line, bfh): + s = line[len(bfh):] + block = blockFixedHuffman + bits |= 1 << 1 + default: + return fmt.Errorf("bad blockZero command: %q", line) + } + + switch s { + case "(final) {": + bits |= 1 + case "(nonFinal) {": + // No-op. + default: + return fmt.Errorf("bad blockZero command: %q", line) + } + + stream.writeBits(bits, 3) + return nil +} + +func doBlockNoCompression(line string) error { + if line == "}" { + if len(bncData) > 0xFFFF { + return fmt.Errorf("bncData is too long") + } + n := uint32(len(bncData)) + stream.flush() + stream.writeBits(n, 16) + stream.writeBits(0xFFFF-n, 16) + stream.writeBytes(bncData) + bncData = bncData[:0] + block = blockZero + return nil + } + + if lit, ok := parseLiteral(line); ok { + bncData = append(bncData, lit...) + return nil + } + + return fmt.Errorf("bad blockNoCompression command: %q", line) +} + +func doBlockFixedHuffman(line string) error { + if line == "}" { + block = blockZero + return nil + } + + if line == "endOfBlock" { + stream.writeBits(0, 7) + return nil + } + + if lit, ok := parseLiteral(line); ok { + // TODO: support "\xAB" escape codes in the script? + for i := 0; i < len(lit); i++ { + stream.writeLCode(uint32(lit[i])) + } + return nil + } + + if l, d, ok := parseLenDist(line); ok { + lCode, lExtra, lNExtra := encodeLength(l) + stream.writeLCode(lCode) + stream.writeBits(lExtra, lNExtra) + dCode, dExtra, dNExtra := encodeDistance(d) + stream.writeBits(reverse(dCode, 5), 5) + stream.writeBits(dExtra, dNExtra) + return nil + } + + return fmt.Errorf("bad blockFixedHuffman command: %q", line) +} + +func encodeLength(l uint32) (code uint32, extra uint32, nExtra uint32) { + switch { + case l < 3: + // No-op. + case l < 11: + l -= 3 + return (l >> 0) + 257, l & 0x0000, 0 + case l < 19: + l -= 11 + return (l >> 1) + 265, l & 0x0001, 1 + case l < 35: + l -= 19 + return (l >> 2) + 269, l & 0x0003, 2 + case l < 67: + l -= 35 + return (l >> 3) + 273, l & 0x0007, 3 + case l < 131: + l -= 67 + return (l >> 4) + 277, l & 0x000F, 4 + case l < 258: + l -= 131 + return (l >> 5) + 281, l & 0x001F, 5 + case l == 258: + return 285, 0, 0 + } + panic(fmt.Sprintf("encodeLength: l=%d", l)) +} + +func encodeDistance(d uint32) (code uint32, extra uint32, nExtra uint32) { + switch { + case d < 1: + // No-op. + case d < 5: + d -= 1 + return (d >> 0) + 0, d & 0x0000, 0 + case d < 9: + d -= 5 + return (d >> 1) + 4, d & 0x0001, 1 + case d < 17: + d -= 9 + return (d >> 2) + 6, d & 0x0003, 2 + case d < 33: + d -= 17 + return (d >> 3) + 8, d & 0x0007, 3 + case d < 65: + d -= 33 + return (d >> 4) + 10, d & 0x000F, 4 + case d < 129: + d -= 65 + return (d >> 5) + 12, d & 0x001F, 5 + case d < 257: + d -= 129 + return (d >> 6) + 14, d & 0x003F, 6 + case d < 513: + d -= 257 + return (d >> 7) + 16, d & 0x007F, 7 + case d < 1025: + d -= 513 + return (d >> 8) + 18, d & 0x00FF, 8 + case d < 2049: + d -= 1025 + return (d >> 9) + 20, d & 0x01FF, 9 + case d < 4097: + d -= 2049 + return (d >> 10) + 22, d & 0x03FF, 10 + case d < 8193: + d -= 4097 + return (d >> 11) + 24, d & 0x07FF, 11 + case d < 16385: + d -= 8193 + return (d >> 12) + 26, d & 0x0FFF, 12 + case d < 32769: + d -= 16385 + return (d >> 13) + 28, d & 0x1FFF, 13 + } + panic(fmt.Sprintf("encodeDistance: d=%d", d)) +} + +func reverse(x uint32, n uint32) uint32 { + x = uint32(reverse8[0xFF&(x>>0)])<<24 | + uint32(reverse8[0xFF&(x>>8)])<<16 | + uint32(reverse8[0xFF&(x>>16)])<<8 | + uint32(reverse8[0xFF&(x>>24)])<<0 + return x >> (32 - n) +} + +var reverse8 = [256]byte{ + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, // 0x00 - 0x07 + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, // 0x08 - 0x0F + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, // 0x10 - 0x17 + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, // 0x18 - 0x1F + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, // 0x20 - 0x27 + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, // 0x28 - 0x2F + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, // 0x30 - 0x37 + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, // 0x38 - 0x3F + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, // 0x40 - 0x47 + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, // 0x48 - 0x4F + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, // 0x50 - 0x57 + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, // 0x58 - 0x5F + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, // 0x60 - 0x67 + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, // 0x68 - 0x6F + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, // 0x70 - 0x77 + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, // 0x78 - 0x7F + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, // 0x80 - 0x87 + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, // 0x88 - 0x8F + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, // 0x90 - 0x97 + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, // 0x98 - 0x9F + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, // 0xA0 - 0xA7 + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, // 0xA8 - 0xAF + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, // 0xB0 - 0xB7 + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, // 0xB8 - 0xBF + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, // 0xC0 - 0xC7 + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, // 0xC8 - 0xCF + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, // 0xD0 - 0xD7 + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, // 0xD8 - 0xDF + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, // 0xE0 - 0xE7 + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, // 0xE8 - 0xEF + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, // 0xF0 - 0xF7 + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF, // 0xF8 - 0xFF +} + +func parseLiteral(s string) (lit string, ok bool) { + const ( + prefix = `literal "` + suffix = `"` + ) + if strings.HasPrefix(s, prefix) { + s = s[len(prefix):] + if strings.HasSuffix(s, suffix) { + return s[:len(s)-len(suffix)], true + } + } + return "", false +} + +func parseLenDist(line string) (l uint32, d uint32, ok bool) { + const ( + lStr = "len " + dStr = "dist " + ) + s := line + if strings.HasPrefix(s, lStr) { + s = s[len(lStr):] + if l, s, ok := parseNum(s); ok && 3 <= l && l <= 258 { + if strings.HasPrefix(s, dStr) { + s = s[len(dStr):] + if d, s, ok := parseNum(s); ok && 1 <= d && d <= 32768 && s == "" { + return l, d, true + } + } + } + } + return 0, 0, false +} + +func parseNum(s string) (num uint32, remaining string, ok bool) { + if i := strings.IndexByte(s, ' '); i >= 0 { + s, remaining = s[:i], s[i+1:] + for len(remaining) > 0 && remaining[0] == ' ' { + remaining = remaining[1:] + } + } + + u, err := strconv.ParseUint(s, 10, 32) + if err != nil { + return 0, "", false + } + return uint32(u), remaining, true +} diff --git a/test/c/std/deflate.c b/test/c/std/deflate.c index 06d6d6fd..178bd032 100644 --- a/test/c/std/deflate.c +++ b/test/c/std/deflate.c @@ -78,6 +78,15 @@ golden_test deflate_deflate_backref_crosses_blocks_gt = { "deflate-backref-crosses-blocks.deflate", }; +golden_test deflate_deflate_distance_32768_gt = { + .want_filename = + "../../data/artificial/" + "deflate-distance-32768.deflate.decompressed", + .src_filename = + "../../data/artificial/" + "deflate-distance-32768.deflate", +}; + golden_test deflate_midsummer_gt = { .want_filename = "../../data/midsummer.txt", // .src_filename = "../../data/midsummer.txt.gz", // @@ -155,12 +164,18 @@ void test_wuffs_deflate_decode_256_bytes() { do_test_buf1_buf1(wuffs_deflate_decode, &deflate_256_bytes_gt, 0, 0); } -void test_wuffs_deflate_decode_flate_backref_crosses_blocks() { +void test_wuffs_deflate_decode_deflate_backref_crosses_blocks() { CHECK_FOCUS(__func__); do_test_buf1_buf1(wuffs_deflate_decode, &deflate_deflate_backref_crosses_blocks_gt, 0, 0); } +void test_wuffs_deflate_decode_deflate_distance_32768() { + CHECK_FOCUS(__func__); + do_test_buf1_buf1(wuffs_deflate_decode, &deflate_deflate_distance_32768_gt, 0, + 0); +} + void test_wuffs_deflate_decode_midsummer() { CHECK_FOCUS(__func__); do_test_buf1_buf1(wuffs_deflate_decode, &deflate_midsummer_gt, 0, 0); @@ -550,12 +565,18 @@ void test_mimic_deflate_decode_256_bytes() { do_test_buf1_buf1(mimic_deflate_decode, &deflate_256_bytes_gt, 0, 0); } -void test_mimic_deflate_decode_flate_backref_crosses_blocks() { +void test_mimic_deflate_decode_deflate_backref_crosses_blocks() { CHECK_FOCUS(__func__); do_test_buf1_buf1(mimic_deflate_decode, &deflate_deflate_backref_crosses_blocks_gt, 0, 0); } +void test_mimic_deflate_decode_deflate_distance_32768() { + CHECK_FOCUS(__func__); + do_test_buf1_buf1(mimic_deflate_decode, &deflate_deflate_distance_32768_gt, 0, + 0); +} + void test_mimic_deflate_decode_midsummer() { CHECK_FOCUS(__func__); do_test_buf1_buf1(mimic_deflate_decode, &deflate_midsummer_gt, 0, 0); @@ -661,28 +682,30 @@ void bench_mimic_gzip_decode_100k() { // The empty comments forces clang-format to place one element per line. proc tests[] = { - test_wuffs_deflate_decode_256_bytes, // - test_wuffs_deflate_decode_flate_backref_crosses_blocks, // - test_wuffs_deflate_decode_midsummer, // - test_wuffs_deflate_decode_pi, // - test_wuffs_deflate_decode_pi_many_big_reads, // - test_wuffs_deflate_decode_pi_many_medium_reads, // - test_wuffs_deflate_decode_pi_many_small_writes_reads, // - test_wuffs_deflate_decode_romeo, // - test_wuffs_deflate_decode_romeo_fixed, // - test_wuffs_deflate_decode_split_src, // - test_wuffs_deflate_history_full, // - test_wuffs_deflate_history_partial, // - test_wuffs_deflate_table_redirect, // + test_wuffs_deflate_decode_256_bytes, // + test_wuffs_deflate_decode_deflate_backref_crosses_blocks, // + // test_wuffs_deflate_decode_deflate_distance_32768, // TODO: uncomment. + test_wuffs_deflate_decode_midsummer, // + test_wuffs_deflate_decode_pi, // + test_wuffs_deflate_decode_pi_many_big_reads, // + test_wuffs_deflate_decode_pi_many_medium_reads, // + test_wuffs_deflate_decode_pi_many_small_writes_reads, // + test_wuffs_deflate_decode_romeo, // + test_wuffs_deflate_decode_romeo_fixed, // + test_wuffs_deflate_decode_split_src, // + test_wuffs_deflate_history_full, // + test_wuffs_deflate_history_partial, // + test_wuffs_deflate_table_redirect, // #ifdef WUFFS_MIMIC - test_mimic_deflate_decode_256_bytes, // - test_mimic_deflate_decode_flate_backref_crosses_blocks, // - test_mimic_deflate_decode_midsummer, // - test_mimic_deflate_decode_pi, // - test_mimic_deflate_decode_romeo, // - test_mimic_deflate_decode_romeo_fixed, // + test_mimic_deflate_decode_256_bytes, // + test_mimic_deflate_decode_deflate_backref_crosses_blocks, // + test_mimic_deflate_decode_deflate_distance_32768, // + test_mimic_deflate_decode_midsummer, // + test_mimic_deflate_decode_pi, // + test_mimic_deflate_decode_romeo, // + test_mimic_deflate_decode_romeo_fixed, // test_mimic_gzip_decode_midsummer, // test_mimic_gzip_decode_pi, // diff --git a/test/data/artificial/deflate-backref-crosses-blocks.deflate.commentary.txt b/test/data/artificial/deflate-backref-crosses-blocks.deflate.commentary.txt index 6936060b..677d4637 100644 --- a/test/data/artificial/deflate-backref-crosses-blocks.deflate.commentary.txt +++ b/test/data/artificial/deflate-backref-crosses-blocks.deflate.commentary.txt @@ -1,33 +1,28 @@ -Running flate-backref-crosses-blocks.flate through script/print-bits.go and +Running deflate-backref-crosses-blocks.deflate 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) + 000000 0x0000 . 0x00 0b_...._.000 Uncompressed block, non-final + 000001 0x0001 . 0x04 0b_0000_0100 Literal length: 0x0004 000002 0x0002 . 0x00 0b_0000_0000 - 000003 0x0003 . 0xFB 0b_1111_1011 + 000003 0x0003 . 0xFB 0b_1111_1011 Inverse: 0xFFFB 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: +The fixed Huffman block contains a back-reference (into the previous block) +then an end of block. The length=3, distance=2 back-reference decodes to "cdc", +so the overall decoding is "abcdcdc". - 000009 0x0009 . 0x03 0b_...._.011 Fixed Huffman block (BTYPE=01), final (BFINAL=1) - - 000009 0x0009 . 0x03 0b_0000_0... (lcode = 257) length = 3 + 000009 0x0009 . 0x03 0b_...._.011 Fixed Huffman block, final + 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_.100_00.. dcode: 1 distance: 2 - 000010 0x000A B 0x42 0b_0..._.... (lcode = 256) end of block + 000010 0x000A B 0x42 0b_0..._.... lcode: 256 end of block 000011 0x000B . 0x00 0b_..00_0000 This back-reference is valid, even though there is no prior data in that block, diff --git a/test/data/artificial/deflate-backref-crosses-blocks.deflate.make.txt b/test/data/artificial/deflate-backref-crosses-blocks.deflate.make.txt new file mode 100644 index 00000000..dfff0b15 --- /dev/null +++ b/test/data/artificial/deflate-backref-crosses-blocks.deflate.make.txt @@ -0,0 +1,12 @@ +# Feed this file to script/make-deflate.go + +blockNoCompression (nonFinal) { + literal "abcd" +} +blockFixedHuffman (final) { + len 3 dist 2 + endOfBlock +} + +# The decompressed data is 4 + 3 = 7 bytes: +# abcdcdc diff --git a/test/data/artificial/deflate-distance-32768.deflate b/test/data/artificial/deflate-distance-32768.deflate new file mode 100644 index 0000000000000000000000000000000000000000..b46350c75c61954a8d6e3746c983427abf46908c GIT binary patch literal 252 xcmebF@$&QZ^*(Q4U}9uuXlg9K)cs{()fBm5Nlo-%e*d3ci}Bun{$2m%836X6bQS;r literal 0 HcmV?d00001 diff --git a/test/data/artificial/deflate-distance-32768.deflate.commentary.txt b/test/data/artificial/deflate-distance-32768.deflate.commentary.txt new file mode 100644 index 00000000..84a30b28 --- /dev/null +++ b/test/data/artificial/deflate-distance-32768.deflate.commentary.txt @@ -0,0 +1,52 @@ +Running deflate-distance-32768.deflate through script/print-bits.go and adding +commentary: + + offset xoffset ASCII hex binary + 000000 0x0000 K 0x4B 0b_...._.011 Fixed Huffman block, final + 000000 0x0000 K 0x4B 0b_0100_1... lcode: 97 literal 'a' + 000001 0x0001 L 0x4C 0b_...._.100 + 000001 0x0001 L 0x4C 0b_0100_1... lcode: 98 literal 'b' + 000002 0x0002 J 0x4A 0b_...._.010 + etc + 000015 0x000F 3 0x33 0b_0011_0... lcode: 55 literal '7' + 000016 0x0010 . 0x1F 0b_...._.111 + 000016 0x0010 . 0x1F 0b_0001_1... lcode: 285 length: 258 + 000017 0x0011 . 0xA5 0b_...._.101 + 000017 0x0011 . 0xA5 0b_1010_0... dcode: 5 base: 7 + 000018 0x0012 G 0x47 0b_...._...1 extra: 1 distance: 8 + 000018 0x0012 G 0x47 0b_0100_011. lcode: 285 length: 258 + 000019 0x0013 . 0xE9 0b_...._...1 + 000019 0x0013 . 0xE9 0b_..10_100. dcode: 5 base: 7 + 000019 0x0013 . 0xE9 0b_.1.._.... extra: 1 distance: 8 + etc + 000236 0x00EC . 0xE9 0b_1..._.... lcode: 284 base: 227 + 000237 0x00ED . 0x91 0b_.001_0001 + 000237 0x00ED . 0x91 0b_1..._.... extra: 17 length: 244 + 000238 0x00EE H 0x48 0b_...._1000 + 000238 0x00EE H 0x48 0b_0100_.... dcode: 5 base: 7 + 000239 0x00EF . 0x03 0b_...._...1 + 000239 0x00EF . 0x03 0b_...._..1. extra: 1 distance: 8 + 000239 0x00EF . 0x03 0b_0000_00.. lcode: 257 length: 3 + 000240 0x00F0 . 0xEF 0b_...._...1 + 000240 0x00F0 . 0xEF 0b_..10_111. dcode: 29 base: 24577 + 000240 0x00F0 . 0xEF 0b_11.._.... extra: 8191 distance: 32768 + 000241 0x00F1 . 0xFF 0b_1111_1111 + 000242 0x00F2 . 0x07 0b_...._.111 + 000242 0x00F2 . 0x07 0b_0000_0... lcode: 257 length: 3 + 000243 0x00F3 * 0x2A 0b_...._..10 + 000243 0x00F3 * 0x2A 0b_.010_10.. dcode: 10 base: 33 + 000243 0x00F3 * 0x2A 0b_0..._.... extra: 2 distance: 35 + 000244 0x00F4 . 0x01 0b_...._.001 + 000244 0x00F4 . 0x01 0b_0000_0... lcode: 257 length: 3 + 000245 0x00F5 . 0xDE 0b_...._..10 + 000245 0x00F5 . 0xDE 0b_.101_11.. dcode: 29 base: 24577 + 000245 0x00F5 . 0xDE 0b_1..._.... extra: 8191 distance: 32768 + 000246 0x00F6 . 0xFF 0b_1111_1111 + 000247 0x00F7 . 0x0F 0b_...._1111 + 000247 0x00F7 . 0x0F 0b_0000_.... lcode: 258 length: 4 + 000248 0x00F8 . 0xBA 0b_...._.010 + 000248 0x00F8 . 0xBA 0b_1011_1... dcode: 29 base: 24577 + 000249 0x00F9 . 0xFE 0b_1111_1110 extra: 8190 distance: 32767 + 000250 0x00FA . 0x1F 0b_...1_1111 + 000250 0x00FA . 0x1F 0b_000._.... lcode: 256 end of block + 000251 0x00FB . 0x00 0b_...._0000 diff --git a/test/data/artificial/deflate-distance-32768.deflate.decompressed b/test/data/artificial/deflate-distance-32768.deflate.decompressed new file mode 100644 index 00000000..3106a044 --- /dev/null +++ b/test/data/artificial/deflate-distance-32768.deflate.decompressed @@ -0,0 +1 @@ +abcdefgh012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567abc012gh02345 \ No newline at end of file diff --git a/test/data/artificial/deflate-distance-32768.deflate.make.txt b/test/data/artificial/deflate-distance-32768.deflate.make.txt new file mode 100644 index 00000000..a6ad2399 --- /dev/null +++ b/test/data/artificial/deflate-distance-32768.deflate.make.txt @@ -0,0 +1,28 @@ +# Feed this file to script/make-deflate.go + +blockFixedHuffman (final) { + # Make 16 + 126*258 + 244 = 32768 bytes: + # abcdefgh0123456701234567...01234567 + literal "abcdefgh01234567" + repeat 126 [ + len 258 dist 8 + ] + len 244 dist 8 + + # Copy "abc". + len 3 dist 32768 + + # Copy "012". + len 3 dist 35 + + # Copy "gh0". + len 3 dist 32768 + + # Copy "2345". + len 4 dist 32767 + + endOfBlock +} + +# The decompressed data is 32768 + 3 + 3 + 3 + 4 = 32781 bytes: +# abcdefgh0123456701234567...01234567abc012gh02345