diff --git a/test/deflate.js b/test/deflate.js index e789f12..c1ed9cf 100644 --- a/test/deflate.js +++ b/test/deflate.js @@ -8,7 +8,7 @@ var zlib = require('zlib'); var pako = require('../index'); var helpers = require('./helpers'); -var testDeflate = helpers.testDeflate; +var testSamples = helpers.testSamples; var samples = helpers.loadSamples(); @@ -17,17 +17,17 @@ var samples = helpers.loadSamples(); describe('Deflate defaults', function () { 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) { - 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 // to ignore some buffer positions 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 () { 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 8 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { level: 8 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 6 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { level: 6 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 4 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { level: 4 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 2 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { level: 2 }, 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) { - 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) { - 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 () { 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 14 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 14 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 12 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 12 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 10 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { windowBits: 10 }, 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) { - 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) { - 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 () { 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 8 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 8 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 6 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 6 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 4 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 4 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { memLevel: 2 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { memLevel: 2 }, 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 () { 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 1 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 1 }, 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) { - testDeflate(zlib.createDeflate, pako.deflate, samples, { strategy: 3 }, done); + testSamples(zlib.createDeflate, pako.deflate, samples, { strategy: 3 }, 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 () { // Since difference is only in rwapper, test for store/fast/slow methods are enougth 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) { - testDeflate(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 1 }, done); + testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 1 }, done); }); it('level 0', function(done) { - testDeflate(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 0 }, done); + testSamples(zlib.createDeflateRaw, pako.deflateRaw, samples, { level: 0 }, done); }); }); diff --git a/test/helpers.js b/test/helpers.js index e2fbef6..7b7eb3e 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -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. // -function testDeflateSingle(zlib_factory, pako_deflate, data, options, callback) { +function testSingle(zlib_factory, pako_deflate, data, options, callback) { var zlib_options = _.clone(options); @@ -95,7 +95,7 @@ function testDeflateSingle(zlib_factory, pako_deflate, data, options, callback) zlibStream.end(); } -function testDeflate(zlib_factory, pako_deflate, samples, options, callback) { +function testSamples(zlib_factory, pako_deflate, samples, options, callback) { var queue = []; _.forEach(samples, function(data, name) { @@ -103,7 +103,7 @@ function testDeflate(zlib_factory, pako_deflate, samples, options, callback) { queue.push(function (done) { pako_utils.setTyped(false); - testDeflateSingle(zlib_factory, pako_deflate, data, options, function (err) { + testSingle(zlib_factory, pako_deflate, data, options, function (err) { if (err) { done('Error in "' + name + '" - zlib result != pako result'); return; @@ -116,7 +116,7 @@ function testDeflate(zlib_factory, pako_deflate, samples, options, callback) { queue.push(function (done) { pako_utils.setTyped(true); - testDeflateSingle(zlib_factory, pako_deflate, data, options, function (err) { + testSingle(zlib_factory, pako_deflate, data, options, function (err) { if (err) { done('Error in "' + name + '" - zlib result != pako result'); return; @@ -166,6 +166,6 @@ function testInflate(samples, inflateOptions, deflateOptions, callback) { exports.cmpBuf = cmpBuf; -exports.testDeflate = testDeflate; +exports.testSamples = testSamples; exports.testInflate = testInflate; exports.loadSamples = loadSamples; \ No newline at end of file diff --git a/test/inflate.js b/test/inflate.js index a0b39cc..dcf2008 100644 --- a/test/inflate.js +++ b/test/inflate.js @@ -26,7 +26,7 @@ describe('Inflate defaults', function () { it.skip('inflate raw from compressed samples', function(done) { 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); }); });