aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorEvgenii Kliuchnikov <eustas@google.com>2023-07-14 07:25:47 -0700
committerCopybara-Service <copybara-worker@google.com>2023-07-14 07:26:14 -0700
commitc2848d5537c0a06aee497dd4fa2cc17505415e19 (patch)
treea77e75b05d6a99b09a14be504c138a513448fe13 /js
parentde52bc7ce07899b940b9120ec01950e171cd1a6a (diff)
downloadbrotli-c2848d5537c0a06aee497dd4fa2cc17505415e19.zip
brotli-c2848d5537c0a06aee497dd4fa2cc17505415e19.tar.gz
brotli-c2848d5537c0a06aee497dd4fa2cc17505415e19.tar.bz2
add synth test for metadata block
PiperOrigin-RevId: 548120163
Diffstat (limited to 'js')
-rw-r--r--js/decode_synth_test.js34
-rw-r--r--js/decode_synth_test.ts34
-rw-r--r--js/jasmine-polyfill.js2
3 files changed, 66 insertions, 4 deletions
diff --git a/js/decode_synth_test.js b/js/decode_synth_test.js
index 197e0ff..3b84545 100644
--- a/js/decode_synth_test.js
+++ b/js/decode_synth_test.js
@@ -1988,6 +1988,37 @@ testOneInsert() {
);
},
+testPeculiarWrap() {
+ const compressed = [
+ 0x21, 0xfc, 0x1f, 0x00, 0x00, 0xa1, 0x12, 0x82, 0x04, 0x60, 0x1d, 0x00,
+ 0xca, 0xfe, 0xba, 0xbe, 0xde, 0xad, 0xbe, 0xef, 0x21, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x4e, 0xdb, 0x00, 0x00, 0x70, 0xb0, 0x65, 0x12, 0x03,
+ 0x24, 0x00, 0x00, 0xee, 0xb4, 0x91, 0x61, 0x68, 0x64, 0x0c
+ ];
+ checkSynth(
+ /*
+ * main_header: 10
+ * // See ZeroCostCommand
+ * metablock_header_begin: 0, 0, 2048, 0
+ * metablock_header_trivial_context
+ * huffman_simple: 0,1,256, 42
+ * huffman_simple: 0,1,704, 130
+ * huffman_simple: 0,1,64, 0
+ * // Metadata block; at least 8 bytes long
+ * bits: "0", "11", "0", "01", "00000111"
+ * byte_boundary
+ * bits: "11001010", "11111110", "10111010", "10111110"
+ * bits: "11011110", "10101101", "10111110", "11101111"
+ * metablock_header_easy: 3, 1
+ * command_easy: 0, "abc", 0
+ */
+ compressed,
+ true,
+ times(512, 'left')
+ + 'abc'
+ );
+},
+
testSimplePrefix() {
const compressed = [
0x1b, 0x03, 0x00, 0x00, 0xa0, 0xc3, 0xc4, 0xc6, 0xc8, 0x02, 0x00, 0x70,
@@ -2053,8 +2084,7 @@ testSimplePrefixOutOfRangeSymbols() {
},
testSimplePrefixPlusExtraData() {
- // SKIP: JS decoder does not tolerate extra input after the brotli stream.
- if ({}.toString() == {}) return; // same as 'if (true) return'
+ if (pending) pending(); else return;
const compressed = [
0x1b, 0x03, 0x00, 0x00, 0xa0, 0xc3, 0xc4, 0xc6, 0xc8, 0x02, 0x00, 0x70,
0xb0, 0x65, 0x12, 0x03, 0x24, 0x00, 0x00, 0xee, 0xb4, 0x51, 0xa0, 0x1d,
diff --git a/js/decode_synth_test.ts b/js/decode_synth_test.ts
index 8a365cd..d5ba950 100644
--- a/js/decode_synth_test.ts
+++ b/js/decode_synth_test.ts
@@ -1978,6 +1978,37 @@ testOneInsert() {
);
},
+testPeculiarWrap() {
+ const compressed = [
+ 0x21, 0xfc, 0x1f, 0x00, 0x00, 0xa1, 0x12, 0x82, 0x04, 0x60, 0x1d, 0x00,
+ 0xca, 0xfe, 0xba, 0xbe, 0xde, 0xad, 0xbe, 0xef, 0x21, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x4e, 0xdb, 0x00, 0x00, 0x70, 0xb0, 0x65, 0x12, 0x03,
+ 0x24, 0x00, 0x00, 0xee, 0xb4, 0x91, 0x61, 0x68, 0x64, 0x0c
+ ];
+ checkSynth(
+ /*
+ * main_header: 10
+ * // See ZeroCostCommand
+ * metablock_header_begin: 0, 0, 2048, 0
+ * metablock_header_trivial_context
+ * huffman_simple: 0,1,256, 42
+ * huffman_simple: 0,1,704, 130
+ * huffman_simple: 0,1,64, 0
+ * // Metadata block; at least 8 bytes long
+ * bits: "0", "11", "0", "01", "00000111"
+ * byte_boundary
+ * bits: "11001010", "11111110", "10111010", "10111110"
+ * bits: "11011110", "10101101", "10111110", "11101111"
+ * metablock_header_easy: 3, 1
+ * command_easy: 0, "abc", 0
+ */
+ compressed,
+ true,
+ times(512, 'left')
+ + 'abc'
+ );
+},
+
testSimplePrefix() {
const compressed = [
0x1b, 0x03, 0x00, 0x00, 0xa0, 0xc3, 0xc4, 0xc6, 0xc8, 0x02, 0x00, 0x70,
@@ -2043,8 +2074,7 @@ testSimplePrefixOutOfRangeSymbols() {
},
testSimplePrefixPlusExtraData() {
- // SKIP: JS decoder does not tolerate extra input after the brotli stream.
- if (2 * 2 === 4) return;
+ if (pending) pending(); else return;
const compressed = [
0x1b, 0x03, 0x00, 0x00, 0xa0, 0xc3, 0xc4, 0xc6, 0xc8, 0x02, 0x00, 0x70,
0xb0, 0x65, 0x12, 0x03, 0x24, 0x00, 0x00, 0xee, 0xb4, 0x51, 0xa0, 0x1d,
diff --git a/js/jasmine-polyfill.js b/js/jasmine-polyfill.js
index 69d7ec4..805c55f 100644
--- a/js/jasmine-polyfill.js
+++ b/js/jasmine-polyfill.js
@@ -3,6 +3,8 @@ goog.require('goog.testing.asserts');
goog.require('goog.testing.jsunit');
let test_case_;
+/** @type{?function(): void} */
+let pending = null;
function describe(caseName, callback) {
test_case_ = new goog.testing.TestCase(caseName);