diff --git a/java/org/brotli/dec/SynthTest.java b/java/org/brotli/dec/SynthTest.java index 4fde1b7..d6be0c6 100644 --- a/java/org/brotli/dec/SynthTest.java +++ b/java/org/brotli/dec/SynthTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Arrays; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -63,6 +62,14 @@ public class SynthTest { } } + private static String times(int count, String str) { + StringBuilder out = new StringBuilder(count * str.length()); + for (int i = 0; i < count; ++i) { + out.append(str); + } + return out.toString(); + } + /* GENERATED CODE START */ @Test @@ -575,7 +582,8 @@ public class SynthTest { */ compressed, true, - "aaaaaaaaaaaaaaaaaaaaaaaaaaaatime" + times(28, "a") + + "time" ); } @@ -839,18 +847,8 @@ public class SynthTest { */ compressed, true, - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -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aaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbb" + times(1022, "a") + + times(10, "b") ); } @@ -2545,13 +2533,7 @@ public class SynthTest { */ compressed, true, - "abababababababababababababababababababababababababababababababababababababababababababababab" - + "ababababababababababababababababababababababababababababababababababababababababababababab" - + "ababababababababababababababababababababababababababababababababababababababababababababab" - + "ababababababababababababababababababababababababababababababababababababababababababababab" - + "ababababababababababababababababababababababababababababababababababababababababababababab" - + "ababababababababababababababababababababababababababababababababababababababababababababab" - + "ababababababababababababababababababababababababababababab" + times(300, "ab") ); } @@ -2769,8 +2751,6 @@ public class SynthTest { (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x03 }; - /* This line is added manually. */ - char[] stub = new char[8388602]; Arrays.fill(stub, 'c'); String hex = "0123456789ABCDEF"; checkSynth( /* * main_header: 24 @@ -2823,8 +2803,10 @@ public class SynthTest { */ compressed, true, - /* This line is modified manually. */ - "abc" + new String(stub) + "abc" + hex + hex + hex + "abc" + + times(8388602, "c") + + "abc" + + times(3, "0123456789ABCDEF") ); } @@ -2907,6 +2889,28 @@ public class SynthTest { ); } + @Test + public void testZeroCostCommand() { + byte[] compressed = { + (byte) 0xa1, (byte) 0xf8, (byte) 0x1f, (byte) 0x00, (byte) 0x00, (byte) 0xa1, (byte) 0x12, + (byte) 0x82, (byte) 0x04, (byte) 0x00 + }; + checkSynth( + /* + * main_header: 10 + * metablock_header_begin: 1, 0, 1024, 0 // last, not empty, length, compressed + * metablock_header_trivial_context + * huffman_simple: 0,1,256, 42 // literal: any + * huffman_simple: 0,1,704, 130 // command: insert = 0, copy = 4, distance_code = -1 + * huffman_simple: 0,1,64, 0 // distance: last + * // 256 0-bit commands with direct distances + */ + compressed, + true, + times(256, "left") + ); + } + @Test public void testZeroCostLiterals() { byte[] compressed = { @@ -2915,8 +2919,6 @@ public class SynthTest { (byte) 0x12, (byte) 0x00, (byte) 0x00, (byte) 0x77, (byte) 0xda, (byte) 0xcc, (byte) 0xe1, (byte) 0x7b, (byte) 0xfa, (byte) 0x0f }; - /* This line is added manually. */ - char[] expected = new char[16777216]; Arrays.fill(expected, '*'); checkSynth( /* * main_header @@ -2930,8 +2932,7 @@ public class SynthTest { */ compressed, true, - /* This line is modified manually. */ - new String(expected) + times(16777216, "*") ); } diff --git a/js/decode_synth_test.js b/js/decode_synth_test.js index 34ab537..197e0ff 100644 --- a/js/decode_synth_test.js +++ b/js/decode_synth_test.js @@ -27,11 +27,11 @@ function bytesToString(bytes) { /** * NB: String.prototype.repeat causes "Maximum call stack size exceeded". * - * @param {string} char * @param {number} count + * @param {string} char * @return {string} */ -function repeat(char, count) { +function times(count, char) { return char.repeat(count); } @@ -495,7 +495,8 @@ testBaseDictWordFinishBlockOnRingbufferWrap() {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a' - + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - + 'aaaaaaaaaaaabbbbbbbbbb' + times(1022, 'a') + + times(10, 'b') ); }, @@ -1918,15 +1893,7 @@ testManyTinyMetablocks() { */ compressed, true, - 'ababababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'ababababababababababab' + times(300, 'ab') ); }, @@ -2126,8 +2093,6 @@ testStressReadDistanceExtraBits() { 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x03 ]; - /* This line is added manually. */ - const stub = repeat("c", 8388602); const hex = "0123456789ABCDEF"; checkSynth( /* * main_header: 24 @@ -2180,8 +2145,10 @@ testStressReadDistanceExtraBits() { */ compressed, true, - /* This line is modified manually. */ - "abc" + stub + "abc" + repeat(hex, 3) + 'abc' + + times(8388602, 'c') + + 'abc' + + times(3, '0123456789ABCDEF') ); }, @@ -2258,13 +2225,31 @@ testTransformedDictWordTooLong() { ); }, +testZeroCostCommand() { + const compressed = [ + 0xa1, 0xf8, 0x1f, 0x00, 0x00, 0xa1, 0x12, 0x82, 0x04, 0x00 + ]; + checkSynth( + /* + * main_header: 10 + * metablock_header_begin: 1, 0, 1024, 0 // last, not empty, length, compressed + * metablock_header_trivial_context + * huffman_simple: 0,1,256, 42 // literal: any + * huffman_simple: 0,1,704, 130 // command: insert = 0, copy = 4, distance_code = -1 + * huffman_simple: 0,1,64, 0 // distance: last + * // 256 0-bit commands with direct distances + */ + compressed, + true, + times(256, 'left') + ); +}, + testZeroCostLiterals() { const compressed = [ 0x9b, 0xff, 0xff, 0xff, 0x00, 0x20, 0x54, 0x00, 0x00, 0x38, 0xd8, 0x32, 0x89, 0x01, 0x12, 0x00, 0x00, 0x77, 0xda, 0xcc, 0xe1, 0x7b, 0xfa, 0x0f ]; - /* This line is added manually. */ - const expected = repeat("*", 16777216); checkSynth( /* * main_header @@ -2278,8 +2263,7 @@ testZeroCostLiterals() { */ compressed, true, - /* This line is modified manually. */ - expected + times(16777216, '*') ); }, diff --git a/js/decode_synth_test.ts b/js/decode_synth_test.ts index 4e6b8b6..8a365cd 100644 --- a/js/decode_synth_test.ts +++ b/js/decode_synth_test.ts @@ -25,7 +25,7 @@ function bytesToString(bytes: Int8Array): string { /** * NB: String.prototype.repeat causes "Maximum call stack size exceeded". */ -function repeat(char:string, count: number): string { +function times(count: number, char:string): string { return char.repeat(count); } @@ -485,7 +485,8 @@ testBaseDictWordFinishBlockOnRingbufferWrap() { */ compressed, true, - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaatime' + times(28, 'a') + + 'time' ); }, @@ -727,21 +728,8 @@ testCompressedUncompressedShortCompressed() { */ compressed, true, - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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bbbbbb' + times(1022, 'a') + + times(10, 'b') ); }, @@ -1908,15 +1883,7 @@ testManyTinyMetablocks() { */ compressed, true, - 'ababababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'abababababababababababababababababababababababababababababababababababab' - + 'ababababababababababab' + times(300, 'ab') ); }, @@ -2116,8 +2083,6 @@ testStressReadDistanceExtraBits() { 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x03 ]; - /* This line is added manually. */ - const stub = repeat("c", 8388602); const hex = "0123456789ABCDEF"; checkSynth( /* * main_header: 24 @@ -2170,8 +2135,10 @@ testStressReadDistanceExtraBits() { */ compressed, true, - /* This line is modified manually. */ - "abc" + stub + "abc" + repeat(hex, 3) + 'abc' + + times(8388602, 'c') + + 'abc' + + times(3, '0123456789ABCDEF') ); }, @@ -2248,13 +2215,31 @@ testTransformedDictWordTooLong() { ); }, +testZeroCostCommand() { + const compressed = [ + 0xa1, 0xf8, 0x1f, 0x00, 0x00, 0xa1, 0x12, 0x82, 0x04, 0x00 + ]; + checkSynth( + /* + * main_header: 10 + * metablock_header_begin: 1, 0, 1024, 0 // last, not empty, length, compressed + * metablock_header_trivial_context + * huffman_simple: 0,1,256, 42 // literal: any + * huffman_simple: 0,1,704, 130 // command: insert = 0, copy = 4, distance_code = -1 + * huffman_simple: 0,1,64, 0 // distance: last + * // 256 0-bit commands with direct distances + */ + compressed, + true, + times(256, 'left') + ); +}, + testZeroCostLiterals() { const compressed = [ 0x9b, 0xff, 0xff, 0xff, 0x00, 0x20, 0x54, 0x00, 0x00, 0x38, 0xd8, 0x32, 0x89, 0x01, 0x12, 0x00, 0x00, 0x77, 0xda, 0xcc, 0xe1, 0x7b, 0xfa, 0x0f ]; - /* This line is added manually. */ - const expected = repeat("*", 16777216); checkSynth( /* * main_header @@ -2268,8 +2253,7 @@ testZeroCostLiterals() { */ compressed, true, - /* This line is modified manually. */ - expected + times(16777216, '*') ); },