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:
Mithun Sasidharan authored and Myles Borins committed 2017-12-12 03:28:31 -05:00
1 parent 28b2d8ac20
commit ff59d3a30e
10 files changed
+66 -62

No files matched your search

+14 -14
View File
@@ -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'
}));
});
}