Added test for ending via push([], true)

This commit is contained in:
Vitaly Puzrin 2014-04-07 08:51:11 +04:00
parent b7943beb1d
commit 4c3761253f

View file

@ -11,6 +11,10 @@ var helpers = require('./helpers');
var pako_utils = require('../lib/zlib/utils');
var pako = require('../index');
var samples = helpers.loadSamples();
function randomBuf(size) {
var buf = pako_utils.Buf8(size);
for (var i = 0; i < size; i++) {
@ -63,4 +67,29 @@ describe('Small input chunks', function () {
testChunk(deflated, buf, new pako.Inflate(), 10);
});
});
});
describe('Dummy push (force end)', function () {
it('deflate end', function () {
var data = samples.lorem_utf_100k;
var deflator = new pako.Deflate();
deflator.push(data);
deflator.push([], true);
assert(helpers.cmpBuf(deflator.result, pako.deflate(data)));
});
it('inflate end', function () {
var data = pako.deflate(samples.lorem_utf_100k);
var inflator = new pako.Inflate();
inflator.push(data);
inflator.push([], true);
assert(helpers.cmpBuf(inflator.result, pako.inflate(data)));
});
});