Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: v7.x - #11122 - test: increase coverage of buffer #11312

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions test/parallel/test-buffer-compare-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ assert.strictEqual(-1, a.compare(b));
// Equivalent to a.compare(b).
assert.strictEqual(-1, a.compare(b, 0));
assert.strictEqual(-1, a.compare(b, '0'));
assert.strictEqual(-1, a.compare(b, undefined));

// Equivalent to a.compare(b).
assert.strictEqual(-1, a.compare(b, 0, undefined, 0));
Expand Down Expand Up @@ -63,5 +64,6 @@ assert.throws(() => a.compare(b, 0, 1, 0, 100), oor);
assert.throws(() => a.compare(b, -1), oor);
assert.throws(() => a.compare(b, 0, '0xff'), oor);
assert.throws(() => a.compare(b, 0, Infinity), oor);
assert.throws(() => a.compare(b, 0, 1, -1), oor);
assert.throws(() => a.compare(b, -Infinity, Infinity), oor);
assert.throws(() => a.compare(), /Argument must be a Buffer/);
11 changes: 11 additions & 0 deletions test/parallel/test-buffer-write-noassert.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ function write(funx, args, result, res) {
);
}

{
const error = /Int/.test(funx) ?
/^TypeError: "buffer" argument must be a Buffer instance$/ :
/^TypeError: argument should be a Buffer$/;

assert.throws(
() => Buffer.alloc(9)[funx].apply(new Uint32Array(1), args),
error
);
}

{
const buf2 = Buffer.alloc(9);
assert.strictEqual(buf2[funx](...args, true), result);
Expand Down