test: validate errors in test-buffer-indexof
* validate errors in assert.throws * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10752 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
77be180f49
commit
f51d4f34ae
@ -344,15 +344,20 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(function() {
|
||||
b.indexOf(function() { });
|
||||
});
|
||||
assert.throws(function() {
|
||||
const argumentExpected =
|
||||
/^TypeError: "val" argument must be string, number, Buffer or Uint8Array$/;
|
||||
|
||||
assert.throws(() => {
|
||||
b.indexOf(() => { });
|
||||
}, argumentExpected);
|
||||
|
||||
assert.throws(() => {
|
||||
b.indexOf({});
|
||||
});
|
||||
assert.throws(function() {
|
||||
}, argumentExpected);
|
||||
|
||||
assert.throws(() => {
|
||||
b.indexOf([]);
|
||||
});
|
||||
}, argumentExpected);
|
||||
|
||||
// All code for handling encodings is shared between Buffer.indexOf and
|
||||
// Buffer.lastIndexOf, so only testing the separate lastIndexOf semantics.
|
||||
|
Loading…
x
Reference in New Issue
Block a user