Skip to content

Commit c034c86

Browse files
TrottMylesBorins
authored andcommitted
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: #8350 Reviewed-By: Anna Henningsen <[email protected]> Reviewed By: James M Snell <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]>
1 parent c094b2a commit c034c86

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
// Check the error condition testing for passing something other than a string
4+
// or buffer.
5+
6+
require('../common');
7+
const assert = require('assert');
8+
const zlib = require('zlib');
9+
10+
const expected = /^TypeError: Not a string or buffer$/;
11+
12+
assert.throws(() => { zlib.deflateSync(undefined); }, expected);
13+
assert.throws(() => { zlib.deflateSync(null); }, expected);
14+
assert.throws(() => { zlib.deflateSync(true); }, expected);
15+
assert.throws(() => { zlib.deflateSync(false); }, expected);
16+
assert.throws(() => { zlib.deflateSync(0); }, expected);
17+
assert.throws(() => { zlib.deflateSync(1); }, expected);
18+
assert.throws(() => { zlib.deflateSync([1, 2, 3]); }, expected);
19+
assert.throws(() => { zlib.deflateSync({foo: 'bar'}); }, expected);

0 commit comments

Comments
 (0)