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>
This commit is contained in:
parent
7b73f55902
commit
9826a79f54
19
test/parallel/test-zlib-not-string-or-buffer.js
Normal file
19
test/parallel/test-zlib-not-string-or-buffer.js
Normal file
@ -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);
|
Loading…
x
Reference in New Issue
Block a user