Skip to content

Commit 901cb8c

Browse files
DavidCai1111jasnell
authored andcommitted
test: increase coverage of buffer
PR-URL: #11122 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 950ef82 commit 901cb8c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

test/parallel/test-buffer-compare-offset.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ assert.strictEqual(-1, a.compare(b));
1111
// Equivalent to a.compare(b).
1212
assert.strictEqual(-1, a.compare(b, 0));
1313
assert.strictEqual(-1, a.compare(b, '0'));
14+
assert.strictEqual(-1, a.compare(b, undefined));
1415

1516
// Equivalent to a.compare(b).
1617
assert.strictEqual(-1, a.compare(b, 0, undefined, 0));
@@ -63,5 +64,6 @@ assert.throws(() => a.compare(b, 0, 1, 0, 100), oor);
6364
assert.throws(() => a.compare(b, -1), oor);
6465
assert.throws(() => a.compare(b, 0, '0xff'), oor);
6566
assert.throws(() => a.compare(b, 0, Infinity), oor);
67+
assert.throws(() => a.compare(b, 0, 1, -1), oor);
6668
assert.throws(() => a.compare(b, -Infinity, Infinity), oor);
6769
assert.throws(() => a.compare(), /Argument must be a Buffer/);

test/parallel/test-buffer-write-noassert.js

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ function write(funx, args, result, res) {
2020
);
2121
}
2222

23+
{
24+
const error = /Int/.test(funx) ?
25+
/^TypeError: "buffer" argument must be a Buffer or Uint8Array$/ :
26+
/^TypeError: argument should be a Buffer$/;
27+
28+
assert.throws(
29+
() => Buffer.alloc(9)[funx].apply(new Uint32Array(1), args),
30+
error
31+
);
32+
}
33+
2334
{
2435
const buf2 = Buffer.alloc(9);
2536
assert.strictEqual(buf2[funx](...args, true), result);

0 commit comments

Comments
 (0)