Skip to content

Commit 752bc24

Browse files
edsadrMylesBorins
authored andcommitted
test: validate errors in test-buffer-indexof
* validate errors in assert.throws * use arrow functions PR-URL: #10752 Backport-PR-URL: #13785 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 9e7f021 commit 752bc24

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/parallel/test-buffer-indexof.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,20 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
346346
}
347347
}
348348

349-
assert.throws(function() {
350-
b.indexOf(function() { });
351-
});
352-
assert.throws(function() {
349+
const argumentExpected =
350+
/^TypeError: "val" argument must be string, number or Buffer$/;
351+
352+
assert.throws(() => {
353+
b.indexOf(() => { });
354+
}, argumentExpected);
355+
356+
assert.throws(() => {
353357
b.indexOf({});
354-
});
355-
assert.throws(function() {
358+
}, argumentExpected);
359+
360+
assert.throws(() => {
356361
b.indexOf([]);
357-
});
362+
}, argumentExpected);
358363

359364
// Test weird offset arguments.
360365
// The following offsets coerce to NaN or 0, searching the whole Buffer

0 commit comments

Comments
 (0)