(samples, deflateOptions, inflateOptions, what)
| 44 | testInflate(samples, {windowBits: -15}, {windowBits: -15}, `windowBits -15`); |
| 45 | |
| 46 | function testInflate(samples, deflateOptions, inflateOptions, what) { |
| 47 | for (let i = 0; i < samples.length; i++) { |
| 48 | const data = samples[i]; |
| 49 | |
| 50 | const deflated = deflate(data, deflateOptions); |
| 51 | const inflated = inflate(deflated, {...inflateOptions, expected: data.byteLength}); |
| 52 | |
| 53 | const src = new Uint8Array(ArrayBuffer.isView(data) ? data.buffer : data); |
| 54 | const dst = new Uint8Array(inflated); |
| 55 | |
| 56 | assert.sameValue(src.byteLength, dst.byteLength, "inflated length should match src length: " + what); |
| 57 | |
| 58 | for (let i = 0, length = src.length; i < length; i++) { |
| 59 | if (src[i] !== inflated[i]) |
| 60 | assert.sameValue(src[i], inflated[i], "inflated data mismatch: " + what); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | function deflate(data, options) { |
| 66 | const deflate = new Deflate(options); |
no test coverage detected