From c034c861bbfe2df142464e6aa76836fd2f3178f9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 30 Aug 2016 19:38:32 -0700 Subject: [PATCH] test: test non-buffer/string with zlib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed By: James M Snell Reviewed-By: Сковорода Никита Андреевич --- .../test-zlib-not-string-or-buffer.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/parallel/test-zlib-not-string-or-buffer.js 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 00000000000000..3f58583e034ca8 --- /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);