|
@ -36,6 +36,10 @@ const opts = { |
|
|
chunkSize: 1024, |
|
|
chunkSize: 1024, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const optsInfo = { |
|
|
|
|
|
info: true |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
for (const [type, expect] of [ |
|
|
for (const [type, expect] of [ |
|
|
['string', expectStr], |
|
|
['string', expectStr], |
|
|
['Buffer', expectBuf], |
|
|
['Buffer', expectBuf], |
|
@ -44,10 +48,10 @@ for (const [type, expect] of [ |
|
|
) |
|
|
) |
|
|
]) { |
|
|
]) { |
|
|
for (const method of [ |
|
|
for (const method of [ |
|
|
['gzip', 'gunzip'], |
|
|
['gzip', 'gunzip', 'Gzip', 'Gunzip'], |
|
|
['gzip', 'unzip'], |
|
|
['gzip', 'unzip', 'Gzip', 'Unzip'], |
|
|
['deflate', 'inflate'], |
|
|
['deflate', 'inflate', 'Deflate', 'Inflate'], |
|
|
['deflateRaw', 'inflateRaw'], |
|
|
['deflateRaw', 'inflateRaw', 'DeflateRaw', 'InflateRaw'], |
|
|
]) { |
|
|
]) { |
|
|
zlib[method[0]](expect, opts, common.mustCall((err, result) => { |
|
|
zlib[method[0]](expect, opts, common.mustCall((err, result) => { |
|
|
zlib[method[1]](result, opts, common.mustCall((err, result) => { |
|
|
zlib[method[1]](result, opts, common.mustCall((err, result) => { |
|
@ -65,6 +69,22 @@ for (const [type, expect] of [ |
|
|
})); |
|
|
})); |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
zlib[method[0]](expect, optsInfo, common.mustCall((err, result) => { |
|
|
|
|
|
assert.ok(result.engine instanceof zlib[method[2]], |
|
|
|
|
|
`Should get engine ${method[2]} after ${method[0]} ` + |
|
|
|
|
|
`${type} with info option.`); |
|
|
|
|
|
|
|
|
|
|
|
const compressed = result.buffer; |
|
|
|
|
|
zlib[method[1]](compressed, optsInfo, common.mustCall((err, result) => { |
|
|
|
|
|
assert.strictEqual(result.buffer.toString(), expectStr, |
|
|
|
|
|
`Should get original string after ${method[0]}/` + |
|
|
|
|
|
`${method[1]} ${type} with info option.`); |
|
|
|
|
|
assert.ok(result.engine instanceof zlib[method[3]], |
|
|
|
|
|
`Should get engine ${method[3]} after ${method[0]} ` + |
|
|
|
|
|
`${type} with info option.`); |
|
|
|
|
|
})); |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
const compressed = zlib[`${method[0]}Sync`](expect, opts); |
|
|
const compressed = zlib[`${method[0]}Sync`](expect, opts); |
|
|
const decompressed = zlib[`${method[1]}Sync`](compressed, opts); |
|
|
const decompressed = zlib[`${method[1]}Sync`](compressed, opts); |
|
@ -81,5 +101,21 @@ for (const [type, expect] of [ |
|
|
`Should get original string after ${method[0]}Sync/` + |
|
|
`Should get original string after ${method[0]}Sync/` + |
|
|
`${method[1]}Sync ${type} without options.`); |
|
|
`${method[1]}Sync ${type} without options.`); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
const compressed = zlib[`${method[0]}Sync`](expect, optsInfo); |
|
|
|
|
|
assert.ok(compressed.engine instanceof zlib[method[2]], |
|
|
|
|
|
`Should get engine ${method[2]} after ${method[0]} ` + |
|
|
|
|
|
`${type} with info option.`); |
|
|
|
|
|
const decompressed = zlib[`${method[1]}Sync`](compressed.buffer, |
|
|
|
|
|
optsInfo); |
|
|
|
|
|
assert.strictEqual(decompressed.buffer.toString(), expectStr, |
|
|
|
|
|
`Should get original string after ${method[0]}Sync/` + |
|
|
|
|
|
`${method[1]}Sync ${type} without options.`); |
|
|
|
|
|
assert.ok(decompressed.engine instanceof zlib[method[3]], |
|
|
|
|
|
`Should get engine ${method[3]} after ${method[0]} ` + |
|
|
|
|
|
`${type} with info option.`); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|