|
@ -24,17 +24,18 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' |
|
|
zlib[methods.comp](inputString, function(err, compressed) { |
|
|
zlib[methods.comp](inputString, function(err, compressed) { |
|
|
assert(!err); |
|
|
assert(!err); |
|
|
const truncated = compressed.slice(0, compressed.length / 2); |
|
|
const truncated = compressed.slice(0, compressed.length / 2); |
|
|
|
|
|
const toUTF8 = (buffer) => buffer.toString('utf-8'); |
|
|
|
|
|
|
|
|
// sync sanity
|
|
|
// sync sanity
|
|
|
assert.doesNotThrow(function() { |
|
|
assert.doesNotThrow(function() { |
|
|
const decompressed = zlib[methods.decompSync](compressed); |
|
|
const decompressed = zlib[methods.decompSync](compressed); |
|
|
assert.equal(decompressed, inputString); |
|
|
assert.strictEqual(toUTF8(decompressed), inputString); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// async sanity
|
|
|
// async sanity
|
|
|
zlib[methods.decomp](compressed, function(err, result) { |
|
|
zlib[methods.decomp](compressed, function(err, result) { |
|
|
assert.ifError(err); |
|
|
assert.ifError(err); |
|
|
assert.equal(result, inputString); |
|
|
assert.strictEqual(toUTF8(result), inputString); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// sync truncated input test
|
|
|
// sync truncated input test
|
|
@ -51,17 +52,15 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' |
|
|
|
|
|
|
|
|
// sync truncated input test, finishFlush = Z_SYNC_FLUSH
|
|
|
// sync truncated input test, finishFlush = Z_SYNC_FLUSH
|
|
|
assert.doesNotThrow(function() { |
|
|
assert.doesNotThrow(function() { |
|
|
const result = zlib[methods.decompSync](truncated, syncFlushOpt) |
|
|
const result = toUTF8(zlib[methods.decompSync](truncated, syncFlushOpt)); |
|
|
.toString(); |
|
|
assert.strictEqual(result, inputString.substr(0, result.length)); |
|
|
assert.equal(result, inputString.substr(0, result.length)); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// async truncated input test, finishFlush = Z_SYNC_FLUSH
|
|
|
// async truncated input test, finishFlush = Z_SYNC_FLUSH
|
|
|
zlib[methods.decomp](truncated, syncFlushOpt, function(err, decompressed) { |
|
|
zlib[methods.decomp](truncated, syncFlushOpt, function(err, decompressed) { |
|
|
assert.ifError(err); |
|
|
assert.ifError(err); |
|
|
|
|
|
const result = toUTF8(decompressed); |
|
|
const result = decompressed.toString(); |
|
|
assert.strictEqual(result, inputString.substr(0, result.length)); |
|
|
assert.equal(result, inputString.substr(0, result.length)); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|