Skip to content

Commit

Permalink
Ignore OS code in gzip test, #107
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Jul 21, 2017
1 parent 4a6867f commit f5f5fea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 2 additions & 3 deletions test/deflate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ describe('Deflate defaults', function () {
testSamples(zlib.deflateRawSync, pako.deflateRaw, samples, {});
});

// OS_CODE can differ. Probably should add param to compare function
// to ignore some buffer positions
// OS code in header can vary. Use hack flag to ignore it.
it('gzip, no options', function () {
testSamples(zlib.gzipSync, pako.gzip, samples, {});
testSamples(zlib.gzipSync, pako.gzip, samples, { ignore_os: true });
});
});

Expand Down
7 changes: 6 additions & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ function testSingle(zlib_method, pako_method, data, options) {
var zlib_result = zlib_method(toBuffer(data), zlib_options);
var pako_result = pako_method(data, options);

assert.deepEqual(zlib_result, pako_result);
// One more hack: gzip header contains OS code, that can vary.
// Override OS code if requested. For simplisity, we assume it on fixed
// position (= no additional gzip headers used)
if (options.ignore_os) zlib_result[9] = pako_result[9];

assert.deepEqual(pako_result, zlib_result);
}


Expand Down

0 comments on commit f5f5fea

Please sign in to comment.