Skip to content

Commit

Permalink
test: add msg validation to test-buffer-compare
Browse files Browse the repository at this point in the history
PR-URL: nodejs#10807
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joshholl authored and italoacasas committed Jan 18, 2017
1 parent 101aa47 commit 003698b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/parallel/test-buffer-compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ assert.strictEqual(Buffer.compare(Buffer.alloc(0), Buffer.alloc(0)), 0);
assert.strictEqual(Buffer.compare(Buffer.alloc(0), Buffer.alloc(1)), -1);
assert.strictEqual(Buffer.compare(Buffer.alloc(1), Buffer.alloc(0)), 1);

assert.throws(() => Buffer.compare(Buffer.alloc(1), 'abc'));
assert.throws(() => Buffer.compare(Buffer.alloc(1), 'abc'),
/^TypeError: Arguments must be Buffers or Uint8Arrays$/);

assert.throws(() => Buffer.compare('abc', Buffer.alloc(1)));
assert.throws(() => Buffer.compare('abc', Buffer.alloc(1)),
/^TypeError: Arguments must be Buffers or Uint8Arrays$/);

assert.throws(() => Buffer.alloc(1).compare('abc'));
assert.throws(() => Buffer.alloc(1).compare('abc'),
/^TypeError: Argument must be a Buffer or Uint8Array$/);

0 comments on commit 003698b

Please sign in to comment.