From f33c96344a1168f18714bd2541d08ce61f1958d1 Mon Sep 17 00:00:00 2001 From: hwaisiu Date: Fri, 6 Oct 2017 10:43:08 -0700 Subject: [PATCH 1/3] test: include value to assert message --- test/parallel/test-zlib-from-concatenated-gzip.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-zlib-from-concatenated-gzip.js b/test/parallel/test-zlib-from-concatenated-gzip.js index 7f3942035a7e04..3cebf9f1d9e202 100644 --- a/test/parallel/test-zlib-from-concatenated-gzip.js +++ b/test/parallel/test-zlib-from-concatenated-gzip.js @@ -7,8 +7,11 @@ 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, @@ -20,13 +23,13 @@ assert.strictEqual(zlib.gunzipSync(data).toString(), 'abcdef'); zlib.gunzip(data, common.mustCall((err, result) => { assert.ifError(err); assert.strictEqual(result.toString(), 'abcdef', - 'result should match original string'); + 'result should match original string: ' + (abc + def)); })); zlib.unzip(data, common.mustCall((err, result) => { assert.ifError(err); assert.strictEqual(result.toString(), 'abcdef', - 'result should match original string'); + 'result should match original string: ' + (abc + def)); })); // Multi-member support does not apply to zlib inflate/deflate. @@ -36,7 +39,7 @@ zlib.unzip(Buffer.concat([ ]), common.mustCall((err, result) => { assert.ifError(err); assert.strictEqual(result.toString(), 'abc', - 'result should match contents of first "member"'); + 'result should match contents of first "member": ' + abc); })); // files that have the "right" magic bytes for starting a new gzip member From a24ecafeead8471ced270ba1689b04d19e9f8836 Mon Sep 17 00:00:00 2001 From: hwaisiu Date: Tue, 10 Oct 2017 19:32:25 -0700 Subject: [PATCH 2/3] Use default message for assert.strictEqual() except the one for asserting First member --- test/parallel/test-zlib-from-concatenated-gzip.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-zlib-from-concatenated-gzip.js b/test/parallel/test-zlib-from-concatenated-gzip.js index 3cebf9f1d9e202..a689ff17a8509b 100644 --- a/test/parallel/test-zlib-from-concatenated-gzip.js +++ b/test/parallel/test-zlib-from-concatenated-gzip.js @@ -18,18 +18,18 @@ const data = Buffer.concat([ 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: ' + (abc + def)); + assert.strictEqual(result.toString(), (abc + def), + `result "${result.toString()}" should match original string: "${(abc + def)}"`); })); zlib.unzip(data, common.mustCall((err, result) => { assert.ifError(err); - assert.strictEqual(result.toString(), 'abcdef', - 'result should match original string: ' + (abc + def)); + assert.strictEqual(result.toString(), (abc + def), + `result "${result.toString()}" should match original string: "${(abc + def)}"`); })); // Multi-member support does not apply to zlib inflate/deflate. @@ -38,8 +38,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": ' + abc); + assert.strictEqual(result.toString(), abc, + `result "${result.toString()}" should match contents of first "member": "${abc}"`); })); // files that have the "right" magic bytes for starting a new gzip member From fee0e72939f89009b2231b7ab713ccd1a4ab077b Mon Sep 17 00:00:00 2001 From: hwaisiu Date: Tue, 10 Oct 2017 20:02:38 -0700 Subject: [PATCH 3/3] test: use default message for assert.strictEqual() test: because of length limit of message --- test/parallel/test-zlib-from-concatenated-gzip.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-zlib-from-concatenated-gzip.js b/test/parallel/test-zlib-from-concatenated-gzip.js index a689ff17a8509b..8f41a673fe450b 100644 --- a/test/parallel/test-zlib-from-concatenated-gzip.js +++ b/test/parallel/test-zlib-from-concatenated-gzip.js @@ -22,14 +22,12 @@ assert.strictEqual(zlib.gunzipSync(data).toString(), (abc + def)); zlib.gunzip(data, common.mustCall((err, result) => { assert.ifError(err); - assert.strictEqual(result.toString(), (abc + def), - `result "${result.toString()}" should match original string: "${(abc + def)}"`); + assert.strictEqual(result.toString(), (abc + def)); })); zlib.unzip(data, common.mustCall((err, result) => { assert.ifError(err); - assert.strictEqual(result.toString(), (abc + def), - `result "${result.toString()}" should match original string: "${(abc + def)}"`); + assert.strictEqual(result.toString(), (abc + def)); })); // Multi-member support does not apply to zlib inflate/deflate. @@ -39,7 +37,7 @@ zlib.unzip(Buffer.concat([ ]), common.mustCall((err, result) => { assert.ifError(err); assert.strictEqual(result.toString(), abc, - `result "${result.toString()}" should match contents of first "member": "${abc}"`); + `First "member": ${result.toString()} === ${abc}`); })); // files that have the "right" magic bytes for starting a new gzip member