MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / testInflate

Function testInflate

tests/modules/data/zlib/deflateinflate.js:46–63  ·  view source on GitHub ↗
(samples, deflateOptions, inflateOptions, what)

Source from the content-addressed store, hash-verified

44testInflate(samples, {windowBits: -15}, {windowBits: -15}, `windowBits -15`);
45
46function 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
65function deflate(data, options) {
66 const deflate = new Deflate(options);

Callers 1

deflateinflate.jsFile · 0.85

Calls 2

deflateFunction · 0.85
inflateFunction · 0.85

Tested by

no test coverage detected