mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-05-04 10:33:48 +01:00
move inflate gzip headers and gzip joined to inflate_gzip
This commit is contained in:
parent
2c28e500e8
commit
4ec36ba40b
2 changed files with 54 additions and 42 deletions
|
@ -4,8 +4,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
var c = require('../lib/zlib/constants');
|
var c = require('../lib/zlib/constants');
|
||||||
|
@ -14,7 +12,6 @@ var zlib_stream = require('../lib/zlib/zstream');
|
||||||
var zlib_inflate = require('../lib/zlib/inflate.js');
|
var zlib_inflate = require('../lib/zlib/inflate.js');
|
||||||
var inflate_table = require('../lib/zlib/inftrees');
|
var inflate_table = require('../lib/zlib/inftrees');
|
||||||
|
|
||||||
var pako_utils = require('../lib/zlib/utils');
|
|
||||||
var pako = require('../index');
|
var pako = require('../index');
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +19,6 @@ function h2b(hex) {
|
||||||
return hex.split(' ').map(function(hex) { return parseInt(hex, 16); });
|
return hex.split(' ').map(function(hex) { return parseInt(hex, 16); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function a2s(array) {
|
|
||||||
return String.fromCharCode.apply(null, array);
|
|
||||||
}
|
|
||||||
|
|
||||||
//step argument from original tests is missing because it have no effect
|
//step argument from original tests is missing because it have no effect
|
||||||
//we have similar behavior in chunks.js tests
|
//we have similar behavior in chunks.js tests
|
||||||
|
@ -246,40 +240,4 @@ describe('Inflate support', function() {
|
||||||
it('bad window size', function() {
|
it('bad window size', function() {
|
||||||
testInflate('', -15, c.Z_OK);
|
testInflate('', -15, c.Z_OK);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('Inflate gzip header', function() {
|
|
||||||
it('Check headers content from prepared file', function() {
|
|
||||||
var data = fs.readFileSync(path.join(__dirname, 'fixtures/gzip-headers.gz'));
|
|
||||||
var inflator = new pako.Inflate();
|
|
||||||
inflator.push(data, true);
|
|
||||||
|
|
||||||
assert.equal(inflator.header.name, 'test name');
|
|
||||||
assert.equal(inflator.header.comment, 'test comment');
|
|
||||||
assert.equal(a2s(inflator.header.extra), 'test extra');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Inflate gzip joined', function() {
|
|
||||||
it('Check content from prepared file', function() {
|
|
||||||
var inflator, strm, _in, len, pos = 0, i = 0;
|
|
||||||
var data = fs.readFileSync(path.join(__dirname, 'fixtures/gzip-joined.gz'));
|
|
||||||
|
|
||||||
do {
|
|
||||||
len = data.length - pos;
|
|
||||||
_in = new pako_utils.Buf8(len);
|
|
||||||
pako_utils.arraySet(_in, data, pos, len, 0);
|
|
||||||
|
|
||||||
inflator = new pako.Inflate();
|
|
||||||
strm = inflator.strm;
|
|
||||||
inflator.push(_in, true);
|
|
||||||
|
|
||||||
assert(!inflator.err, inflator.msg);
|
|
||||||
|
|
||||||
pos += strm.next_in_index;
|
|
||||||
i++;
|
|
||||||
} while (strm.avail_in);
|
|
||||||
|
|
||||||
assert(i === 2, 'invalid blobs count');
|
|
||||||
});
|
|
||||||
});
|
});
|
54
test/inflate_gzip.js
Normal file
54
test/inflate_gzip.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*global describe, it*/
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
|
var pako_utils = require('../lib/zlib/utils');
|
||||||
|
var pako = require('../index');
|
||||||
|
|
||||||
|
|
||||||
|
function a2s(array) {
|
||||||
|
return String.fromCharCode.apply(null, array);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('Inflate gzip header', function() {
|
||||||
|
it('Check headers content from prepared file', function() {
|
||||||
|
var data = fs.readFileSync(path.join(__dirname, 'fixtures/gzip-headers.gz'));
|
||||||
|
var inflator = new pako.Inflate();
|
||||||
|
inflator.push(data, true);
|
||||||
|
|
||||||
|
assert.equal(inflator.header.name, 'test name');
|
||||||
|
assert.equal(inflator.header.comment, 'test comment');
|
||||||
|
assert.equal(a2s(inflator.header.extra), 'test extra');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Inflate gzip joined', function() {
|
||||||
|
it('Check content from prepared file', function() {
|
||||||
|
var inflator, strm, _in, len, pos = 0, i = 0;
|
||||||
|
var data = fs.readFileSync(path.join(__dirname, 'fixtures/gzip-joined.gz'));
|
||||||
|
|
||||||
|
do {
|
||||||
|
len = data.length - pos;
|
||||||
|
_in = new pako_utils.Buf8(len);
|
||||||
|
pako_utils.arraySet(_in, data, pos, len, 0);
|
||||||
|
|
||||||
|
inflator = new pako.Inflate();
|
||||||
|
strm = inflator.strm;
|
||||||
|
inflator.push(_in, true);
|
||||||
|
|
||||||
|
assert(!inflator.err, inflator.msg);
|
||||||
|
|
||||||
|
pos += strm.next_in_index;
|
||||||
|
i++;
|
||||||
|
} while (strm.avail_in);
|
||||||
|
|
||||||
|
assert(i === 2, 'invalid blobs count');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue