Browse Source

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>
v7.x
Adrian Estrada 8 years ago
committed by Italo A. Casas
parent
commit
807e99b81d
No known key found for this signature in database GPG Key ID: 23EFEFE93C4CFFFE
  1. 19
      test/parallel/test-buffer-indexof.js

19
test/parallel/test-buffer-indexof.js

@ -337,15 +337,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 or Buffer$/;
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…
Cancel
Save