summaryrefslogtreecommitdiff
path: root/test/parallel/test-zlib-not-string-or-buffer.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-08-30 19:38:32 -0700
committerRich Trott <rtrott@gmail.com>2016-09-02 13:39:31 -0700
commit9826a79f54f83cf67c258ffbe34bfca121394f35 (patch)
treee3517192b3458abe4729dfdd86f7d5ace8f28960 /test/parallel/test-zlib-not-string-or-buffer.js
parent7b73f559029a10474b74a83bfb1117ab512785d4 (diff)
downloadandroid-node-v8-9826a79f54f83cf67c258ffbe34bfca121394f35.tar.gz
android-node-v8-9826a79f54f83cf67c258ffbe34bfca121394f35.tar.bz2
android-node-v8-9826a79f54f83cf67c258ffbe34bfca121394f35.zip
test: test non-buffer/string with zlib
Check the error condition testing for passing something other than a string or buffer. Currently, there are no tests for this. PR-URL: https://github.com/nodejs/node/pull/8350 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Diffstat (limited to 'test/parallel/test-zlib-not-string-or-buffer.js')
-rw-r--r--test/parallel/test-zlib-not-string-or-buffer.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/parallel/test-zlib-not-string-or-buffer.js b/test/parallel/test-zlib-not-string-or-buffer.js
new file mode 100644
index 0000000000..3f58583e03
--- /dev/null
+++ b/test/parallel/test-zlib-not-string-or-buffer.js
@@ -0,0 +1,19 @@
+'use strict';
+
+// Check the error condition testing for passing something other than a string
+// or buffer.
+
+require('../common');
+const assert = require('assert');
+const zlib = require('zlib');
+
+const expected = /^TypeError: Not a string or buffer$/;
+
+assert.throws(() => { zlib.deflateSync(undefined); }, expected);
+assert.throws(() => { zlib.deflateSync(null); }, expected);
+assert.throws(() => { zlib.deflateSync(true); }, expected);
+assert.throws(() => { zlib.deflateSync(false); }, expected);
+assert.throws(() => { zlib.deflateSync(0); }, expected);
+assert.throws(() => { zlib.deflateSync(1); }, expected);
+assert.throws(() => { zlib.deflateSync([1, 2, 3]); }, expected);
+assert.throws(() => { zlib.deflateSync({foo: 'bar'}); }, expected);