Skip to content

Commit

Permalink
test: validate errors in test-buffer-indexof
Browse files Browse the repository at this point in the history
* validate errors in assert.throws
* use arrow functions

PR-URL: nodejs#10752
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
edsadr authored and italoacasas committed Jan 18, 2017
1 parent 7790a34 commit 1e3dac6
Showing 1 changed file with 12 additions and 7 deletions.
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

0 comments on commit 1e3dac6

Please sign in to comment.