summaryrefslogtreecommitdiff
path: root/test/parallel/test-zlib-flush-flags.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-04-06 00:54:34 +0200
committerAnna Henningsen <anna@addaleax.net>2016-04-17 17:01:55 +0200
commit978166796edb5a867a9152f8a2a1ae35899e4000 (patch)
tree243f50dcfdbd147c88906a224a06d3b61858440b /test/parallel/test-zlib-flush-flags.js
parentf49a1d050178cbaab7732e8643c4db33c4b81ede (diff)
downloadandroid-node-v8-978166796edb5a867a9152f8a2a1ae35899e4000.tar.gz
android-node-v8-978166796edb5a867a9152f8a2a1ae35899e4000.tar.bz2
android-node-v8-978166796edb5a867a9152f8a2a1ae35899e4000.zip
zlib: Make the finish flush flag configurable
Up to now, `Z_FINISH` was always the flushing flag that was used for the last chunk of input data. This patch makes this choice configurable so that advanced users can perform e.g. decompression of partial data using `Z_SYNC_FLUSH`, if that suits their needs. Add tests to make sure that an error is thrown upon encountering invalid `flush` or `finishFlush` flags. Fixes: https://github.com/nodejs/node/issues/5761 PR-URL: https://github.com/nodejs/node/pull/6069 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-zlib-flush-flags.js')
-rw-r--r--test/parallel/test-zlib-flush-flags.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/parallel/test-zlib-flush-flags.js b/test/parallel/test-zlib-flush-flags.js
new file mode 100644
index 0000000000..08c79f138b
--- /dev/null
+++ b/test/parallel/test-zlib-flush-flags.js
@@ -0,0 +1,28 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+const zlib = require('zlib');
+
+assert.doesNotThrow(() => {
+ zlib.createGzip({ flush: zlib.Z_SYNC_FLUSH });
+});
+
+assert.throws(() => {
+ zlib.createGzip({ flush: 'foobar' });
+}, /Invalid flush flag: foobar/);
+
+assert.throws(() => {
+ zlib.createGzip({ flush: 10000 });
+}, /Invalid flush flag: 10000/);
+
+assert.doesNotThrow(() => {
+ zlib.createGzip({ finishFlush: zlib.Z_SYNC_FLUSH });
+});
+
+assert.throws(() => {
+ zlib.createGzip({ finishFlush: 'foobar' });
+}, /Invalid flush flag: foobar/);
+
+assert.throws(() => {
+ zlib.createGzip({ finishFlush: 10000 });
+}, /Invalid flush flag: 10000/);