Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: validate errors in test-buffer-indexof
* validate errors in assert.throws
* use arrow functions
  • Loading branch information
edsadr committed Jan 12, 2017
commit 7282a6b81cd631ac49656c175c7b515b27355e38
19 changes: 12 additions & 7 deletions test/parallel/test-buffer-indexof.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down