You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var zlibjs = require('zlibjs');
function do_test(src) {
var srcStr = JSON.stringify(src);
try{
var compressed = zlibjs.deflateSync(src);
var inflated = zlibjs.inflateSync(compressed);
var inflatedStr = JSON.stringify(inflated);
if (srcStr!=inflatedStr) {
console.log("not equal: " + srcStr + " to " + inflatedStr);
}
}catch(ex){
console.log(ex.message, "src:"+srcStr);
}
}
// success
do_test([0,1,2,3,4,5,6,7]);
// not equal
do_test([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,0,0,0,0,0,0,97,0,0,215,0,0,0,0,0,97,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,174,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,166,0,0,0,0,101,0,0,0,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186,0,111,0,0,218,0,0,0,0,0,0,0,0,0,0,0,111]);
do_test([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,231,0,0,0,0,0,0,0,0,22,8,0,0,0,0,0,0,0,0,0,0,0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,243,0,194,0,0,0,0,8,0,0,0,0,0,0,9,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,86,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,45,0,0,0,0,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,0,0,191,0,0,108,0,0,0,0,169,0,0,60,0,0,0,0,165,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,168,0,0,0,0,0,0,0,0,0,0,0,0,0,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
// take a long time and finally throw an exception
do_test([125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,150,0,237,0,41,0,0,0,0,0,0,0,0,54,0,90,0,0,0,0,0,0,0,0,4,0,72,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,140,103,0,145,170,0,0,0,0,0,0,0,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,33,0,0,0,0,0,0,0,163,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,230,0,0,0,0,0,0,0,0,0,0,0,122,0,0,0,0,0,0,0,196,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,111,0,0,0,0,0,56,0,0,0,0,0,0,0,0,0,133,0,0,0,0,6,0,0,0,0,215,21,0,0,0,0]);
// random test
/*
for(var i=0;i<10000;++i) {
var bf = new Buffer(Math.floor(Math.random()*300));
for(var j=0;j<bf.length;++j) bf[j] = (Math.random()<0.9) ? 0 : Math.floor(Math.random()*256);
do_test(bf);
}
*/
The text was updated successfully, but these errors were encountered:
Here is a reproduction code written with node.js:
The text was updated successfully, but these errors were encountered: