Ignore OS code in gzip test, #107

This commit is contained in:
Vitaly Puzrin 2017-07-21 23:00:02 +03:00
parent 4a6867f633
commit f5f5fea962
2 changed files with 8 additions and 4 deletions

View file

@ -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 });
});
});

View file

@ -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);
}