Skip to content

Commit

Permalink
test: test non-buffer/string with zlib
Browse files Browse the repository at this point in the history
Check the error condition testing for passing something other than a
string or buffer. Currently, there are no tests for this.

PR-URL: #8350
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
  • Loading branch information
Trott committed Sep 2, 2016
1 parent 7b73f55 commit 9826a79
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/parallel/test-zlib-not-string-or-buffer.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 9826a79

Please sign in to comment.