mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: replace assert.throws w/ common.expectsError
PR-URL: https://github.com/nodejs/node/pull/17483 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
28b2d8ac20
commit
ff59d3a30e
10 files changed
+66
-62
No files matched your search
@@ -65,16 +65,16 @@ b.writeDoubleBE(11.11, 0, true);
|
||||
buf[0] = 9;
|
||||
assert.strictEqual(ab[1], 9);
|
||||
|
||||
assert.throws(() => Buffer.from(ab.buffer, 6), common.expectsError({
|
||||
common.expectsError(() => Buffer.from(ab.buffer, 6), {
|
||||
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||
type: RangeError,
|
||||
message: '"offset" is outside of buffer bounds'
|
||||
}));
|
||||
assert.throws(() => Buffer.from(ab.buffer, 3, 6), common.expectsError({
|
||||
});
|
||||
common.expectsError(() => Buffer.from(ab.buffer, 3, 6), {
|
||||
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||
type: RangeError,
|
||||
message: '"length" is outside of buffer bounds'
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
// Test the deprecated Buffer() version also
|
||||
@@ -93,16 +93,16 @@ b.writeDoubleBE(11.11, 0, true);
|
||||
buf[0] = 9;
|
||||
assert.strictEqual(ab[1], 9);
|
||||
|
||||
assert.throws(() => Buffer(ab.buffer, 6), common.expectsError({
|
||||
common.expectsError(() => Buffer(ab.buffer, 6), {
|
||||
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||
type: RangeError,
|
||||
message: '"offset" is outside of buffer bounds'
|
||||
}));
|
||||
assert.throws(() => Buffer(ab.buffer, 3, 6), common.expectsError({
|
||||
});
|
||||
common.expectsError(() => Buffer(ab.buffer, 3, 6), {
|
||||
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||
type: RangeError,
|
||||
message: '"length" is outside of buffer bounds'
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
@@ -118,13 +118,13 @@ b.writeDoubleBE(11.11, 0, true);
|
||||
assert.deepStrictEqual(Buffer.from(ab, [1]), Buffer.from(ab, 1));
|
||||
|
||||
// If byteOffset is Infinity, throw.
|
||||
assert.throws(() => {
|
||||
common.expectsError(() => {
|
||||
Buffer.from(ab, Infinity);
|
||||
}, common.expectsError({
|
||||
}, {
|
||||
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||
type: RangeError,
|
||||
message: '"offset" is outside of buffer bounds'
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
@@ -140,11 +140,11 @@ b.writeDoubleBE(11.11, 0, true);
|
||||
assert.deepStrictEqual(Buffer.from(ab, 0, [1]), Buffer.from(ab, 0, 1));
|
||||
|
||||
//If length is Infinity, throw.
|
||||
assert.throws(() => {
|
||||
common.expectsError(() => {
|
||||
Buffer.from(ab, 0, Infinity);
|
||||
}, common.expectsError({
|
||||
}, {
|
||||
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||
type: RangeError,
|
||||
message: '"length" is outside of buffer bounds'
|
||||
}));
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user