mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-05 19:31:01 +01:00
helper rename
This commit is contained in:
parent
8cbe85f55f
commit
57a80d98cf
3 changed files with 48 additions and 48 deletions
|
@ -8,7 +8,7 @@ var zlib = require('zlib');
|
||||||
|
|
||||||
var pako = require('../index');
|
var pako = require('../index');
|
||||||
var helpers = require('./helpers');
|
var helpers = require('./helpers');
|
||||||
var testDeflate = helpers.testDeflate;
|
var testSamples = helpers.testSamples;
|
||||||
|
|
||||||
|
|
||||||
var samples = helpers.loadSamples();
|
var samples = helpers.loadSamples();
|
||||||
|
@ -17,17 +17,17 @@ var samples = helpers.loadSamples();
|
||||||
describe('Deflate defaults', function () {
|
describe('Deflate defaults', function () {
|
||||||
|
|
||||||
it('deflate, no options', function(done) {
|
it('deflate, no options', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, {}, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('deflate raw, no options', function(done) {
|
it('deflate raw, no options', function(done) {
|
||||||
testDeflate(zlib.createDeflateRaw, pako.deflateRaw, samples, {}, done);
|
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
// OS_CODE can differ. Probably should add param to compare function
|
// OS_CODE can differ. Probably should add param to compare function
|
||||||
// to ignore some buffer positions
|
// to ignore some buffer positions
|
||||||
it('gzip, no options', function(done) {
|
it('gzip, no options', function(done) {
|
||||||
testDeflate(zlib.createGzip, pako.gzip, samples, {}, done);
|
testSamples(zlib.createGzip, pako.gzip, samples, {}, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,37 +35,37 @@ describe('Deflate defaults', function () {
|
||||||
describe('Deflate levels', function () {
|
describe('Deflate levels', function () {
|
||||||
|
|
||||||
it('level 9', function(done) {
|
it('level 9', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 9 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 9 }, done);
|
||||||
});
|
});
|
||||||
it('level 8', function(done) {
|
it('level 8', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 8 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 8 }, done);
|
||||||
});
|
});
|
||||||
it('level 7', function(done) {
|
it('level 7', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 7 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 7 }, done);
|
||||||
});
|
});
|
||||||
it('level 6', function(done) {
|
it('level 6', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 6 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 6 }, done);
|
||||||
});
|
});
|
||||||
it('level 5', function(done) {
|
it('level 5', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 5 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 5 }, done);
|
||||||
});
|
});
|
||||||
it('level 4', function(done) {
|
it('level 4', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 4 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 4 }, done);
|
||||||
});
|
});
|
||||||
it('level 3', function(done) {
|
it('level 3', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 3 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 3 }, done);
|
||||||
});
|
});
|
||||||
it('level 2', function(done) {
|
it('level 2', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 2 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 2 }, done);
|
||||||
});
|
});
|
||||||
it('level 1', function(done) {
|
it('level 1', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 1 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 1 }, done);
|
||||||
});
|
});
|
||||||
it('level 0', function(done) {
|
it('level 0', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
||||||
});
|
});
|
||||||
it('level -1 (implicit default)', function(done) {
|
it('level -1 (implicit default)', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,31 +73,31 @@ describe('Deflate levels', function () {
|
||||||
describe('Deflate windowBits', function () {
|
describe('Deflate windowBits', function () {
|
||||||
|
|
||||||
it('windowBits 15', function(done) {
|
it('windowBits 15', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 15 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 15 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 14', function(done) {
|
it('windowBits 14', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 14 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 14 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 13', function(done) {
|
it('windowBits 13', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 13 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 13 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 12', function(done) {
|
it('windowBits 12', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 12 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 12 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 11', function(done) {
|
it('windowBits 11', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 11 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 11 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 10', function(done) {
|
it('windowBits 10', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 10 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 10 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 9', function(done) {
|
it('windowBits 9', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 9 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 9 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits 8', function(done) {
|
it('windowBits 8', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 8 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 8 }, done);
|
||||||
});
|
});
|
||||||
it('windowBits -15 (implicit raw)', function(done) {
|
it('windowBits -15 (implicit raw)', function(done) {
|
||||||
testDeflate(zlib.createDeflateRaw, pako.deflate, samples, { windowBits: -15 }, done);
|
testSamples(zlib.createDeflateRaw, pako.deflate, samples, { windowBits: -15 }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -106,31 +106,31 @@ describe('Deflate windowBits', function () {
|
||||||
describe('Deflate memLevel', function () {
|
describe('Deflate memLevel', function () {
|
||||||
|
|
||||||
it('memLevel 9', function(done) {
|
it('memLevel 9', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 9 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 9 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 8', function(done) {
|
it('memLevel 8', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 8 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 8 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 7', function(done) {
|
it('memLevel 7', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 7 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 7 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 6', function(done) {
|
it('memLevel 6', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 6 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 6 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 5', function(done) {
|
it('memLevel 5', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 5 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 5 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 4', function(done) {
|
it('memLevel 4', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 4 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 4 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 3', function(done) {
|
it('memLevel 3', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 3 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 3 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 2', function(done) {
|
it('memLevel 2', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 2 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 2 }, done);
|
||||||
});
|
});
|
||||||
it('memLevel 1', function(done) {
|
it('memLevel 1', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 1 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 1 }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -139,19 +139,19 @@ describe('Deflate memLevel', function () {
|
||||||
describe('Deflate strategy', function () {
|
describe('Deflate strategy', function () {
|
||||||
|
|
||||||
it('Z_DEFAULT_STRATEGY', function(done) {
|
it('Z_DEFAULT_STRATEGY', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 0 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 0 }, done);
|
||||||
});
|
});
|
||||||
it('Z_FILTERED', function(done) {
|
it('Z_FILTERED', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 1 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 1 }, done);
|
||||||
});
|
});
|
||||||
it('Z_HUFFMAN_ONLY', function(done) {
|
it('Z_HUFFMAN_ONLY', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 2 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 2 }, done);
|
||||||
});
|
});
|
||||||
it('Z_RLE', function(done) {
|
it('Z_RLE', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 3 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 3 }, done);
|
||||||
});
|
});
|
||||||
it('Z_FIXED', function(done) {
|
it('Z_FIXED', function(done) {
|
||||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 4 }, done);
|
testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 4 }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -160,13 +160,13 @@ describe('Deflate strategy', function () {
|
||||||
describe('Deflate RAW', function () {
|
describe('Deflate RAW', function () {
|
||||||
// Since difference is only in rwapper, test for store/fast/slow methods are enougth
|
// Since difference is only in rwapper, test for store/fast/slow methods are enougth
|
||||||
it('level 4', function(done) {
|
it('level 4', function(done) {
|
||||||
testDeflate(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 4 }, done);
|
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 4 }, done);
|
||||||
});
|
});
|
||||||
it('level 1', function(done) {
|
it('level 1', function(done) {
|
||||||
testDeflate(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 1 }, done);
|
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 1 }, done);
|
||||||
});
|
});
|
||||||
it('level 0', function(done) {
|
it('level 0', function(done) {
|
||||||
testDeflate(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 0 }, done);
|
testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 0 }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,10 +49,10 @@ function cmpBuf(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper to test deflate/deflateRaw with different options.
|
// Helper to test deflate/inflate with different options.
|
||||||
// Use zlib streams, because it's the only way to define options.
|
// Use zlib streams, because it's the only way to define options.
|
||||||
//
|
//
|
||||||
function testDeflateSingle(zlib_factory, pako_deflate, data, options, callback) {
|
function testSingle(zlib_factory, pako_deflate, data, options, callback) {
|
||||||
|
|
||||||
var zlib_options = _.clone(options);
|
var zlib_options = _.clone(options);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ function testDeflateSingle(zlib_factory, pako_deflate, data, options, callback)
|
||||||
zlibStream.end();
|
zlibStream.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDeflate(zlib_factory, pako_deflate, samples, options, callback) {
|
function testSamples(zlib_factory, pako_deflate, samples, options, callback) {
|
||||||
var queue = [];
|
var queue = [];
|
||||||
|
|
||||||
_.forEach(samples, function(data, name) {
|
_.forEach(samples, function(data, name) {
|
||||||
|
@ -103,7 +103,7 @@ function testDeflate(zlib_factory, pako_deflate, samples, options, callback) {
|
||||||
queue.push(function (done) {
|
queue.push(function (done) {
|
||||||
pako_utils.setTyped(false);
|
pako_utils.setTyped(false);
|
||||||
|
|
||||||
testDeflateSingle(zlib_factory, pako_deflate, data, options, function (err) {
|
testSingle(zlib_factory, pako_deflate, data, options, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
done('Error in "' + name + '" - zlib result != pako result');
|
done('Error in "' + name + '" - zlib result != pako result');
|
||||||
return;
|
return;
|
||||||
|
@ -116,7 +116,7 @@ function testDeflate(zlib_factory, pako_deflate, samples, options, callback) {
|
||||||
queue.push(function (done) {
|
queue.push(function (done) {
|
||||||
pako_utils.setTyped(true);
|
pako_utils.setTyped(true);
|
||||||
|
|
||||||
testDeflateSingle(zlib_factory, pako_deflate, data, options, function (err) {
|
testSingle(zlib_factory, pako_deflate, data, options, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
done('Error in "' + name + '" - zlib result != pako result');
|
done('Error in "' + name + '" - zlib result != pako result');
|
||||||
return;
|
return;
|
||||||
|
@ -166,6 +166,6 @@ function testInflate(samples, inflateOptions, deflateOptions, callback) {
|
||||||
|
|
||||||
|
|
||||||
exports.cmpBuf = cmpBuf;
|
exports.cmpBuf = cmpBuf;
|
||||||
exports.testDeflate = testDeflate;
|
exports.testSamples = testSamples;
|
||||||
exports.testInflate = testInflate;
|
exports.testInflate = testInflate;
|
||||||
exports.loadSamples = loadSamples;
|
exports.loadSamples = loadSamples;
|
|
@ -26,7 +26,7 @@ describe('Inflate defaults', function () {
|
||||||
|
|
||||||
it.skip('inflate raw from compressed samples', function(done) {
|
it.skip('inflate raw from compressed samples', function(done) {
|
||||||
var compressed_samples = helpers.loadSamples('samples_deflated_raw');
|
var compressed_samples = helpers.loadSamples('samples_deflated_raw');
|
||||||
helpers.testDeflate(zlib.createInflateRaw, pako.inflateRaw, compressed_samples, {}, done);
|
helpers.testSamples(zlib.createInflateRaw, pako.inflateRaw, compressed_samples, {}, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue