-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
277 additions
and
212 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
test/parallel/test-zlib-invalid-arg-value-brotli-compress.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
'use strict'; | ||
|
||
// Check the error condition testing for passing something other than a string | ||
// or buffer. | ||
const { invalidArgTypeHelper } = require('../common'); | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const zlib = require('zlib'); | ||
const assert = require('node:assert'); | ||
const zlib = require('node:zlib'); | ||
const { test } = require('node:test'); | ||
|
||
[ | ||
undefined, | ||
null, | ||
true, | ||
false, | ||
0, | ||
1, | ||
[1, 2, 3], | ||
{ foo: 'bar' }, | ||
].forEach((input) => { | ||
assert.throws( | ||
() => zlib.deflateSync(input), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
message: 'The "buffer" argument must be of type string or an instance ' + | ||
'of Buffer, TypedArray, DataView, or ArrayBuffer.' + | ||
common.invalidArgTypeHelper(input) | ||
} | ||
); | ||
// Check the error condition testing for passing something other than a string | ||
// or buffer. | ||
test('check zlib for not string or buffer inputs', async (t) => { | ||
[ | ||
undefined, | ||
null, | ||
true, | ||
false, | ||
0, | ||
1, | ||
[1, 2, 3], | ||
{ foo: 'bar' }, | ||
].forEach((input) => { | ||
assert.throws( | ||
() => zlib.deflateSync(input), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
message: 'The "buffer" argument must be of type string or an instance ' + | ||
'of Buffer, TypedArray, DataView, or ArrayBuffer.' + | ||
invalidArgTypeHelper(input) | ||
} | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { Gunzip } = require('zlib'); | ||
require('../common'); | ||
|
||
const gunzip = new Gunzip({ objectMode: true }); | ||
gunzip.on('error', common.mustNotCall()); | ||
assert.throws(() => { | ||
gunzip.write({}); | ||
}, { | ||
name: 'TypeError', | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
const assert = require('node:assert'); | ||
const { Gunzip } = require('node:zlib'); | ||
const { test } = require('node:test'); | ||
|
||
test('zlib object write', async (t) => { | ||
const { promise, resolve, reject } = Promise.withResolvers(); | ||
const gunzip = new Gunzip({ objectMode: true }); | ||
gunzip.on('error', reject); | ||
gunzip.on('close', resolve); | ||
assert.throws(() => { | ||
gunzip.write({}); | ||
}, { | ||
name: 'TypeError', | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
gunzip.close(); | ||
await promise; | ||
}); |
Oops, something went wrong.