'use strict';
var Buffer = require('../../').Buffer;
-
+var common = require('../common');
var assert = require('assert');
buf[0] = 9;
assert.equal(ab[1], 9);
- assert.throws(() => Buffer.from(ab.buffer, 6), (err) => {
- assert(err instanceof RangeError);
- assert(/'offset' is out of bounds/.test(err.message));
- return true;
+ 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), (err) => {
- assert(err instanceof RangeError);
- assert(/'length' is out of bounds/.test(err.message));
- return true;
+ common.expectsError(() => Buffer.from(ab.buffer, 3, 6), {
+ code: 'ERR_BUFFER_OUT_OF_BOUNDS',
+ type: RangeError,
+ message: '"length" is outside of buffer bounds'
});
}
buf[0] = 9;
assert.equal(ab[1], 9);
- assert.throws(() => Buffer(ab.buffer, 6), (err) => {
- assert(err instanceof RangeError);
- assert(/'offset' is out of bounds/.test(err.message));
- return true;
+ 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), (err) => {
- assert(err instanceof RangeError);
- assert(/'length' is out of bounds/.test(err.message));
- return true;
+ common.expectsError(() => Buffer(ab.buffer, 3, 6), {
+ code: 'ERR_BUFFER_OUT_OF_BOUNDS',
+ type: RangeError,
+ message: '"length" is outside of buffer bounds'
});
}