mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-04 10:50:59 +01:00
Tests cleanup: use modern sync zlib api
This commit is contained in:
parent
dfc3b0e2a1
commit
374b277da9
4 changed files with 187 additions and 243 deletions
|
@ -26,7 +26,6 @@
|
|||
"repository": "nodeca/pako",
|
||||
"devDependencies": {
|
||||
"ansi": "*",
|
||||
"async": "*",
|
||||
"benchmark": "*",
|
||||
"bluebird": "^3.5.0",
|
||||
"browserify": "*",
|
||||
|
@ -36,7 +35,6 @@
|
|||
"grunt-contrib-connect": "^1.0.2",
|
||||
"grunt-saucelabs": "^9.0.0",
|
||||
"istanbul": "*",
|
||||
"lodash": "*",
|
||||
"mocha": "^3.2.0",
|
||||
"multiparty": "^4.1.3",
|
||||
"ndoc": "*",
|
||||
|
|
168
test/deflate.js
168
test/deflate.js
|
@ -20,88 +20,88 @@ var samples = helpers.loadSamples();
|
|||
|
||||
describe('Deflate defaults', function () {
|
||||
|
||||
it('deflate, no options', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, {}, done);
|
||||
it('deflate, no options', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, {});
|
||||
});
|
||||
|
||||
it('deflate raw, no options', function (done) {
|
||||
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, {}, done);
|
||||
it('deflate raw, no options', function () {
|
||||
testSamples(zlib.deflateRawSync, pako.deflateRaw, samples, {});
|
||||
});
|
||||
|
||||
// OS_CODE can differ. Probably should add param to compare function
|
||||
// to ignore some buffer positions
|
||||
it('gzip, no options', function (done) {
|
||||
testSamples(zlib.createGzip, pako.gzip, samples, {}, done);
|
||||
it('gzip, no options', function () {
|
||||
testSamples(zlib.gzipSync, pako.gzip, samples, {});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Deflate levels', function () {
|
||||
|
||||
it('level 9', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 9 }, done);
|
||||
it('level 9', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 9 });
|
||||
});
|
||||
it('level 8', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 8 }, done);
|
||||
it('level 8', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 8 });
|
||||
});
|
||||
it('level 7', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 7 }, done);
|
||||
it('level 7', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 7 });
|
||||
});
|
||||
it('level 6', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 6 }, done);
|
||||
it('level 6', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 6 });
|
||||
});
|
||||
it('level 5', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 5 }, done);
|
||||
it('level 5', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 5 });
|
||||
});
|
||||
it('level 4', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 4 }, done);
|
||||
it('level 4', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 4 });
|
||||
});
|
||||
it('level 3', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 3 }, done);
|
||||
it('level 3', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 3 });
|
||||
});
|
||||
it('level 2', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 2 }, done);
|
||||
it('level 2', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 2 });
|
||||
});
|
||||
it('level 1', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 1 }, done);
|
||||
it('level 1', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 1 });
|
||||
});
|
||||
it('level 0', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
||||
it('level 0', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 0 });
|
||||
});
|
||||
it('level -1 (implicit default)', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
||||
it('level -1 (implicit default)', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { level: 0 });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Deflate windowBits', function () {
|
||||
|
||||
it('windowBits 15', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 15 }, done);
|
||||
it('windowBits 15', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 15 });
|
||||
});
|
||||
it('windowBits 14', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 14 }, done);
|
||||
it('windowBits 14', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 14 });
|
||||
});
|
||||
it('windowBits 13', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 13 }, done);
|
||||
it('windowBits 13', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 13 });
|
||||
});
|
||||
it('windowBits 12', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 12 }, done);
|
||||
it('windowBits 12', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 12 });
|
||||
});
|
||||
it('windowBits 11', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 11 }, done);
|
||||
it('windowBits 11', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 11 });
|
||||
});
|
||||
it('windowBits 10', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 10 }, done);
|
||||
it('windowBits 10', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 10 });
|
||||
});
|
||||
it('windowBits 9', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 9 }, done);
|
||||
it('windowBits 9', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 9 });
|
||||
});
|
||||
it('windowBits 8', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 8 }, done);
|
||||
it('windowBits 8', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { windowBits: 8 });
|
||||
});
|
||||
it('windowBits -15 (implicit raw)', function (done) {
|
||||
testSamples(zlib.createDeflateRaw, pako.deflate, samples, { windowBits: -15 }, done);
|
||||
it('windowBits -15 (implicit raw)', function () {
|
||||
testSamples(zlib.deflateRawSync, pako.deflate, samples, { windowBits: -15 });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -109,32 +109,32 @@ describe('Deflate windowBits', function () {
|
|||
|
||||
describe('Deflate memLevel', function () {
|
||||
|
||||
it('memLevel 9', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 9 }, done);
|
||||
it('memLevel 9', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 9 });
|
||||
});
|
||||
it('memLevel 8', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 8 }, done);
|
||||
it('memLevel 8', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 8 });
|
||||
});
|
||||
it('memLevel 7', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 7 }, done);
|
||||
it('memLevel 7', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 7 });
|
||||
});
|
||||
it('memLevel 6', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 6 }, done);
|
||||
it('memLevel 6', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 6 });
|
||||
});
|
||||
it('memLevel 5', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 5 }, done);
|
||||
it('memLevel 5', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 5 });
|
||||
});
|
||||
it('memLevel 4', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 4 }, done);
|
||||
it('memLevel 4', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 4 });
|
||||
});
|
||||
it('memLevel 3', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 3 }, done);
|
||||
it('memLevel 3', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 3 });
|
||||
});
|
||||
it('memLevel 2', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 2 }, done);
|
||||
it('memLevel 2', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 2 });
|
||||
});
|
||||
it('memLevel 1', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 1 }, done);
|
||||
it('memLevel 1', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { memLevel: 1 });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -142,20 +142,20 @@ describe('Deflate memLevel', function () {
|
|||
|
||||
describe('Deflate strategy', function () {
|
||||
|
||||
it('Z_DEFAULT_STRATEGY', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 0 }, done);
|
||||
it('Z_DEFAULT_STRATEGY', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { strategy: 0 });
|
||||
});
|
||||
it('Z_FILTERED', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 1 }, done);
|
||||
it('Z_FILTERED', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { strategy: 1 });
|
||||
});
|
||||
it('Z_HUFFMAN_ONLY', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 2 }, done);
|
||||
it('Z_HUFFMAN_ONLY', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { strategy: 2 });
|
||||
});
|
||||
it('Z_RLE', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 3 }, done);
|
||||
it('Z_RLE', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { strategy: 3 });
|
||||
});
|
||||
it('Z_FIXED', function (done) {
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 4 }, done);
|
||||
it('Z_FIXED', function () {
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { strategy: 4 });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -163,14 +163,14 @@ describe('Deflate strategy', function () {
|
|||
|
||||
describe('Deflate RAW', function () {
|
||||
// Since difference is only in rwapper, test for store/fast/slow methods are enougth
|
||||
it('level 4', function (done) {
|
||||
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 4 }, done);
|
||||
it('level 4', function () {
|
||||
testSamples(zlib.deflateRawSync, pako.deflateRaw, samples, { level: 4 });
|
||||
});
|
||||
it('level 1', function (done) {
|
||||
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 1 }, done);
|
||||
it('level 1', function () {
|
||||
testSamples(zlib.deflateRawSync, pako.deflateRaw, samples, { level: 1 });
|
||||
});
|
||||
it('level 0', function (done) {
|
||||
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 0 }, done);
|
||||
it('level 0', function () {
|
||||
testSamples(zlib.deflateRawSync, pako.deflateRaw, samples, { level: 0 });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -178,15 +178,15 @@ describe('Deflate RAW', function () {
|
|||
|
||||
describe('Deflate dictionary', function () {
|
||||
|
||||
it('trivial dictionary', function (done) {
|
||||
it('trivial dictionary', function () {
|
||||
var dict = new Buffer('abcdefghijklmnoprstuvwxyz');
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { dictionary: dict }, done);
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { dictionary: dict });
|
||||
});
|
||||
|
||||
it('spdy dictionary', function (done) {
|
||||
it('spdy dictionary', function () {
|
||||
var spdyDict = require('fs').readFileSync(require('path').join(__dirname, 'fixtures', 'spdy_dict.txt'));
|
||||
|
||||
testSamples(zlib.createDeflate, pako.deflate, samples, { dictionary: spdyDict }, done);
|
||||
testSamples(zlib.deflateSync, pako.deflate, samples, { dictionary: spdyDict });
|
||||
});
|
||||
|
||||
it('handles multiple pushes', function () {
|
||||
|
|
100
test/helpers.js
100
test/helpers.js
|
@ -1,10 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var _ = require('lodash');
|
||||
var async = require('async');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
|
||||
var pako_utils = require('../lib/utils/common');
|
||||
var pako = require('../index');
|
||||
|
@ -49,87 +48,42 @@ function cmpBuf(a, b) {
|
|||
}
|
||||
|
||||
|
||||
function toBuffer(src) { return Buffer.from ? Buffer.from(src) : new Buffer(src); }
|
||||
|
||||
|
||||
// Helper to test deflate/inflate with different options.
|
||||
// Use zlib streams, because it's the only way to define options.
|
||||
//
|
||||
function testSingle(zlib_factory, pako_deflate, data, options, callback) {
|
||||
|
||||
var zlib_options = _.clone(options);
|
||||
function testSingle(zlib_method, pako_method, data, options) {
|
||||
var zlib_options = Object.assign({}, options);
|
||||
|
||||
// hack for testing negative windowBits
|
||||
if (zlib_options.windowBits < 0) { zlib_options.windowBits = -zlib_options.windowBits; }
|
||||
|
||||
var zlibStream = zlib_factory(zlib_options);
|
||||
var buffers = [];
|
||||
var zlib_result = zlib_method(toBuffer(data), zlib_options);
|
||||
var pako_result = pako_method(data, options);
|
||||
|
||||
|
||||
zlibStream.on('error', function (err) {
|
||||
zlibStream.removeAllListeners();
|
||||
zlibStream = null;
|
||||
callback(err);
|
||||
});
|
||||
|
||||
zlibStream.on('data', function (chunk) {
|
||||
buffers.push(chunk);
|
||||
});
|
||||
|
||||
zlibStream.on('end', function () {
|
||||
zlibStream.removeAllListeners();
|
||||
zlibStream = null;
|
||||
|
||||
var buffer = Buffer.concat(buffers);
|
||||
|
||||
var pako_result = pako_deflate(data, options);
|
||||
|
||||
if (!cmpBuf(buffer, pako_result)) {
|
||||
callback(new Error('zlib result != pako result'));
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
|
||||
|
||||
zlibStream.write(new Buffer(data));
|
||||
zlibStream.end();
|
||||
assert.deepEqual(zlib_result, pako_result);
|
||||
}
|
||||
|
||||
function testSamples(zlib_factory, pako_deflate, samples, options, callback) {
|
||||
var queue = [];
|
||||
|
||||
_.forEach(samples, function (data, name) {
|
||||
function testSamples(zlib_method, pako_method, samples, options) {
|
||||
|
||||
Object.keys(samples).forEach(function (name) {
|
||||
var data = samples[name];
|
||||
|
||||
// with untyped arrays
|
||||
queue.push(function (done) {
|
||||
pako_utils.setTyped(false);
|
||||
|
||||
testSingle(zlib_factory, pako_deflate, data, options, function (err) {
|
||||
if (err) {
|
||||
done('Error in "' + name + '" - zlib result != pako result');
|
||||
return;
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
pako_utils.setTyped(false);
|
||||
testSingle(zlib_method, pako_method, data, options);
|
||||
|
||||
// with typed arrays
|
||||
queue.push(function (done) {
|
||||
pako_utils.setTyped(true);
|
||||
|
||||
testSingle(zlib_factory, pako_deflate, data, options, function (err) {
|
||||
if (err) {
|
||||
done('Error in "' + name + '" - zlib result != pako result');
|
||||
return;
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
pako_utils.setTyped(true);
|
||||
testSingle(zlib_method, pako_method, data, options);
|
||||
});
|
||||
|
||||
async.series(queue, callback);
|
||||
}
|
||||
|
||||
|
||||
function testInflate(samples, inflateOptions, deflateOptions, callback) {
|
||||
function testInflate(samples, inflateOptions, deflateOptions) {
|
||||
var name, data, deflated, inflated;
|
||||
|
||||
// inflate options have windowBits = 0 to force autodetect window size
|
||||
|
@ -147,21 +101,13 @@ function testInflate(samples, inflateOptions, deflateOptions, callback) {
|
|||
inflated = pako.inflate(deflated, inflateOptions);
|
||||
pako_utils.setTyped(true);
|
||||
|
||||
if (!cmpBuf(inflated, data)) {
|
||||
callback('Error in "' + name + '" - inflate result != original');
|
||||
return;
|
||||
}
|
||||
assert.deepEqual(inflated, data);
|
||||
|
||||
// with typed arrays
|
||||
inflated = pako.inflate(deflated, inflateOptions);
|
||||
|
||||
if (!cmpBuf(inflated, data)) {
|
||||
callback('Error in "' + name + '" - inflate result != original');
|
||||
return;
|
||||
}
|
||||
assert.deepEqual(inflated, data);
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
|
||||
|
|
160
test/inflate.js
160
test/inflate.js
|
@ -16,64 +16,64 @@ var samples = helpers.loadSamples();
|
|||
|
||||
describe('Inflate defaults', function () {
|
||||
|
||||
it('inflate, no options', function (done) {
|
||||
testInflate(samples, {}, {}, done);
|
||||
it('inflate, no options', function () {
|
||||
testInflate(samples, {}, {});
|
||||
});
|
||||
|
||||
it('inflate raw, no options', function (done) {
|
||||
testInflate(samples, { raw: true }, { raw: true }, done);
|
||||
it('inflate raw, no options', function () {
|
||||
testInflate(samples, { raw: true }, { raw: true });
|
||||
});
|
||||
|
||||
it('inflate raw from compressed samples', function (done) {
|
||||
it('inflate raw from compressed samples', function () {
|
||||
var compressed_samples = helpers.loadSamples('samples_deflated_raw');
|
||||
helpers.testSamples(zlib.createInflateRaw, pako.inflateRaw, compressed_samples, {}, done);
|
||||
helpers.testSamples(zlib.inflateRawSync, pako.inflateRaw, compressed_samples, {});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('Inflate ungzip', function () {
|
||||
it('with autodetect', function (done) {
|
||||
testInflate(samples, {}, { gzip: true }, done);
|
||||
it('with autodetect', function () {
|
||||
testInflate(samples, {}, { gzip: true });
|
||||
});
|
||||
|
||||
it('with method set directly', function (done) {
|
||||
testInflate(samples, { windowBits: 16 }, { gzip: true }, done);
|
||||
it('with method set directly', function () {
|
||||
testInflate(samples, { windowBits: 16 }, { gzip: true });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Inflate levels', function () {
|
||||
|
||||
it('level 9', function (done) {
|
||||
testInflate(samples, {}, { level: 9 }, done);
|
||||
it('level 9', function () {
|
||||
testInflate(samples, {}, { level: 9 });
|
||||
});
|
||||
it('level 8', function (done) {
|
||||
testInflate(samples, {}, { level: 8 }, done);
|
||||
it('level 8', function () {
|
||||
testInflate(samples, {}, { level: 8 });
|
||||
});
|
||||
it('level 7', function (done) {
|
||||
testInflate(samples, {}, { level: 7 }, done);
|
||||
it('level 7', function () {
|
||||
testInflate(samples, {}, { level: 7 });
|
||||
});
|
||||
it('level 6', function (done) {
|
||||
testInflate(samples, {}, { level: 6 }, done);
|
||||
it('level 6', function () {
|
||||
testInflate(samples, {}, { level: 6 });
|
||||
});
|
||||
it('level 5', function (done) {
|
||||
testInflate(samples, {}, { level: 5 }, done);
|
||||
it('level 5', function () {
|
||||
testInflate(samples, {}, { level: 5 });
|
||||
});
|
||||
it('level 4', function (done) {
|
||||
testInflate(samples, {}, { level: 4 }, done);
|
||||
it('level 4', function () {
|
||||
testInflate(samples, {}, { level: 4 });
|
||||
});
|
||||
it('level 3', function (done) {
|
||||
testInflate(samples, {}, { level: 3 }, done);
|
||||
it('level 3', function () {
|
||||
testInflate(samples, {}, { level: 3 });
|
||||
});
|
||||
it('level 2', function (done) {
|
||||
testInflate(samples, {}, { level: 2 }, done);
|
||||
it('level 2', function () {
|
||||
testInflate(samples, {}, { level: 2 });
|
||||
});
|
||||
it('level 1', function (done) {
|
||||
testInflate(samples, {}, { level: 1 }, done);
|
||||
it('level 1', function () {
|
||||
testInflate(samples, {}, { level: 1 });
|
||||
});
|
||||
it('level 0', function (done) {
|
||||
testInflate(samples, {}, { level: 0 }, done);
|
||||
it('level 0', function () {
|
||||
testInflate(samples, {}, { level: 0 });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -81,49 +81,49 @@ describe('Inflate levels', function () {
|
|||
|
||||
describe('Inflate windowBits', function () {
|
||||
|
||||
it('windowBits 15', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 15 }, done);
|
||||
it('windowBits 15', function () {
|
||||
testInflate(samples, {}, { windowBits: 15 });
|
||||
});
|
||||
it('windowBits 14', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 14 }, done);
|
||||
it('windowBits 14', function () {
|
||||
testInflate(samples, {}, { windowBits: 14 });
|
||||
});
|
||||
it('windowBits 13', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 13 }, done);
|
||||
it('windowBits 13', function () {
|
||||
testInflate(samples, {}, { windowBits: 13 });
|
||||
});
|
||||
it('windowBits 12', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 12 }, done);
|
||||
it('windowBits 12', function () {
|
||||
testInflate(samples, {}, { windowBits: 12 });
|
||||
});
|
||||
it('windowBits 11', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 11 }, done);
|
||||
it('windowBits 11', function () {
|
||||
testInflate(samples, {}, { windowBits: 11 });
|
||||
});
|
||||
it('windowBits 10', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 10 }, done);
|
||||
it('windowBits 10', function () {
|
||||
testInflate(samples, {}, { windowBits: 10 });
|
||||
});
|
||||
it('windowBits 9', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 9 }, done);
|
||||
it('windowBits 9', function () {
|
||||
testInflate(samples, {}, { windowBits: 9 });
|
||||
});
|
||||
it('windowBits 8', function (done) {
|
||||
testInflate(samples, {}, { windowBits: 8 }, done);
|
||||
it('windowBits 8', function () {
|
||||
testInflate(samples, {}, { windowBits: 8 });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Inflate strategy', function () {
|
||||
|
||||
it('Z_DEFAULT_STRATEGY', function (done) {
|
||||
testInflate(samples, {}, { strategy: 0 }, done);
|
||||
it('Z_DEFAULT_STRATEGY', function () {
|
||||
testInflate(samples, {}, { strategy: 0 });
|
||||
});
|
||||
it('Z_FILTERED', function (done) {
|
||||
testInflate(samples, {}, { strategy: 1 }, done);
|
||||
it('Z_FILTERED', function () {
|
||||
testInflate(samples, {}, { strategy: 1 });
|
||||
});
|
||||
it('Z_HUFFMAN_ONLY', function (done) {
|
||||
testInflate(samples, {}, { strategy: 2 }, done);
|
||||
it('Z_HUFFMAN_ONLY', function () {
|
||||
testInflate(samples, {}, { strategy: 2 });
|
||||
});
|
||||
it('Z_RLE', function (done) {
|
||||
testInflate(samples, {}, { strategy: 3 }, done);
|
||||
it('Z_RLE', function () {
|
||||
testInflate(samples, {}, { strategy: 3 });
|
||||
});
|
||||
it('Z_FIXED', function (done) {
|
||||
testInflate(samples, {}, { strategy: 4 }, done);
|
||||
it('Z_FIXED', function () {
|
||||
testInflate(samples, {}, { strategy: 4 });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -131,35 +131,35 @@ describe('Inflate strategy', function () {
|
|||
|
||||
describe('Inflate RAW', function () {
|
||||
// Since difference is only in rwapper, test for store/fast/slow methods are enougth
|
||||
it('level 9', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 9, raw: true }, done);
|
||||
it('level 9', function () {
|
||||
testInflate(samples, { raw: true }, { level: 9, raw: true });
|
||||
});
|
||||
it('level 8', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 8, raw: true }, done);
|
||||
it('level 8', function () {
|
||||
testInflate(samples, { raw: true }, { level: 8, raw: true });
|
||||
});
|
||||
it('level 7', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 7, raw: true }, done);
|
||||
it('level 7', function () {
|
||||
testInflate(samples, { raw: true }, { level: 7, raw: true });
|
||||
});
|
||||
it('level 6', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 6, raw: true }, done);
|
||||
it('level 6', function () {
|
||||
testInflate(samples, { raw: true }, { level: 6, raw: true });
|
||||
});
|
||||
it('level 5', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 5, raw: true }, done);
|
||||
it('level 5', function () {
|
||||
testInflate(samples, { raw: true }, { level: 5, raw: true });
|
||||
});
|
||||
it('level 4', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 4, raw: true }, done);
|
||||
it('level 4', function () {
|
||||
testInflate(samples, { raw: true }, { level: 4, raw: true });
|
||||
});
|
||||
it('level 3', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 3, raw: true }, done);
|
||||
it('level 3', function () {
|
||||
testInflate(samples, { raw: true }, { level: 3, raw: true });
|
||||
});
|
||||
it('level 2', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 2, raw: true }, done);
|
||||
it('level 2', function () {
|
||||
testInflate(samples, { raw: true }, { level: 2, raw: true });
|
||||
});
|
||||
it('level 1', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 1, raw: true }, done);
|
||||
it('level 1', function () {
|
||||
testInflate(samples, { raw: true }, { level: 1, raw: true });
|
||||
});
|
||||
it('level 0', function (done) {
|
||||
testInflate(samples, { raw: true }, { level: 0, raw: true }, done);
|
||||
it('level 0', function () {
|
||||
testInflate(samples, { raw: true }, { level: 0, raw: true });
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -176,15 +176,15 @@ describe('Inflate with dictionary', function () {
|
|||
}, /data error/);
|
||||
});
|
||||
|
||||
it('trivial dictionary', function (done) {
|
||||
it('trivial dictionary', function () {
|
||||
var dict = new Buffer('abcdefghijklmnoprstuvwxyz');
|
||||
testInflate(samples, { dictionary: dict }, { dictionary: dict }, done);
|
||||
testInflate(samples, { dictionary: dict }, { dictionary: dict });
|
||||
});
|
||||
|
||||
it('spdy dictionary', function (done) {
|
||||
it('spdy dictionary', function () {
|
||||
var spdyDict = require('fs').readFileSync(require('path').join(__dirname, 'fixtures', 'spdy_dict.txt'));
|
||||
|
||||
testInflate(samples, { dictionary: spdyDict }, { dictionary: helpers.spdyDict }, done);
|
||||
testInflate(samples, { dictionary: spdyDict }, { dictionary: helpers.spdyDict });
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue