mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-04 10:50:59 +01:00
added coverage generation & improved tests
This commit is contained in:
parent
a131622863
commit
5cabad0d48
9 changed files with 27 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
/doc
|
||||
/node_modules/
|
||||
/coverage
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
.git/
|
||||
node_modules/
|
||||
benchmark/implementations
|
||||
coverage/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/banchmark/
|
||||
/benchmark/
|
||||
/test/
|
||||
/coverage/
|
||||
/.*
|
||||
/Makefile
|
||||
|
||||
|
|
3
Makefile
3
Makefile
|
@ -35,6 +35,9 @@ test: lint
|
|||
fi
|
||||
mocha
|
||||
|
||||
cover:
|
||||
rm -rf cover
|
||||
istanbul cover node_modules/.bin/_mocha -- -t 30000 -R spec
|
||||
|
||||
doc:
|
||||
@if test ! `which ndoc` ; then \
|
||||
|
|
|
@ -93,7 +93,7 @@ function sliceBuf(buf, size) {
|
|||
var Deflate = function(options) {
|
||||
|
||||
this.options = utils.assign({
|
||||
level: 6,
|
||||
level: c.Z_DEFAULT_COMPRESSION,
|
||||
method: c.Z_DEFLATED,
|
||||
chunkSize: 16384,
|
||||
windowBits: 15,
|
||||
|
|
|
@ -1206,14 +1206,16 @@ function DeflateState() {
|
|||
}
|
||||
|
||||
function deflateResetKeep(strm) {
|
||||
strm.total_in = strm.total_out = 0;
|
||||
strm.data_type = c.Z_UNKNOWN;
|
||||
var s;
|
||||
|
||||
if (!strm || !strm.state) {
|
||||
return c.Z_STREAM_ERROR;
|
||||
}
|
||||
|
||||
var s = strm.state;
|
||||
strm.total_in = strm.total_out = 0;
|
||||
strm.data_type = c.Z_UNKNOWN;
|
||||
|
||||
s = strm.state;
|
||||
s.pending = 0;
|
||||
s.pending_out = 0;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ function ZStream() {
|
|||
/* not visible by applications */
|
||||
this.state = null;
|
||||
/* best guess about the data type: binary or text */
|
||||
this.data_type = 2;
|
||||
this.data_type = 2/*Z_UNKNOWN*/;
|
||||
/* adler32 value of the uncompressed data */
|
||||
this.adler = 0;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,9 @@ describe('Deflate levels', function () {
|
|||
it('level 0', function(done) {
|
||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
||||
});
|
||||
|
||||
it('level -1 (implicit default)', function(done) {
|
||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
@ -94,6 +96,9 @@ describe('Deflate windowBits', function () {
|
|||
it('windowBits 8', function(done) {
|
||||
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 8 }, done);
|
||||
});
|
||||
it('windowBits -15 (implicit raw)', function(done) {
|
||||
testDeflate(zlib.createDeflateRaw, pako.deflate, samples, { windowBits: -15 }, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -54,7 +54,12 @@ function cmpBuf(a, b) {
|
|||
//
|
||||
function testDeflateSingle(zlib_factory, pako_deflate, data, options, callback) {
|
||||
|
||||
var zlibStream = zlib_factory(options);
|
||||
var zlib_options = _.clone(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 = [], nread = 0;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue