Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions test/parallel/test-zlib-from-concatenated-gzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,27 @@ const zlib = require('zlib');
const fs = require('fs');
const fixtures = require('../common/fixtures');

const abcEncoded = zlib.gzipSync('abc');
const defEncoded = zlib.gzipSync('def');
const abc = 'abc';
const def = 'def';

const abcEncoded = zlib.gzipSync(abc);
const defEncoded = zlib.gzipSync(def);

const data = Buffer.concat([
abcEncoded,
defEncoded
]);

assert.strictEqual(zlib.gunzipSync(data).toString(), 'abcdef');
assert.strictEqual(zlib.gunzipSync(data).toString(), (abc + def));

zlib.gunzip(data, common.mustCall((err, result) => {
assert.ifError(err);
assert.strictEqual(result.toString(), 'abcdef',
'result should match original string');
assert.strictEqual(result.toString(), (abc + def));
}));

zlib.unzip(data, common.mustCall((err, result) => {
assert.ifError(err);
assert.strictEqual(result.toString(), 'abcdef',
'result should match original string');
assert.strictEqual(result.toString(), (abc + def));
}));

// Multi-member support does not apply to zlib inflate/deflate.
Expand All @@ -35,8 +36,8 @@ zlib.unzip(Buffer.concat([
zlib.deflateSync('def')
]), common.mustCall((err, result) => {
assert.ifError(err);
assert.strictEqual(result.toString(), 'abc',
'result should match contents of first "member"');
assert.strictEqual(result.toString(), abc,
`First "member": ${result.toString()} === ${abc}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually more readable if the assertion message is removed.

}));

// files that have the "right" magic bytes for starting a new gzip member
Expand Down