Skip to content

Commit

Permalink
test: increase buffer list coverage
Browse files Browse the repository at this point in the history
1. test consuming BufferList which has strings with > 1 items
Refs: https://coverage.nodejs.org/coverage-0b6d3070a176d437/lib/internal/streams/buffer_list.js.html#L116

2. test consuming BufferList with > 1 items
Refs: https://coverage.nodejs.org/coverage-0b6d3070a176d437/lib/internal/streams/buffer_list.js.html#L152

PR-URL: #36688
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
emilsivervik authored and ruyadorno committed Jan 21, 2021
1 parent d3f7280 commit 951a78b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/parallel/test-stream-buffer-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,37 @@ const shifted = list.shift();
testIterator(list, 0);
assert.strictEqual(shifted, buf);
assert.deepStrictEqual(list, new BufferList());

{
const list = new BufferList();
list.push('foo');
list.push('bar');
list.push('foo');
list.push('bar');
assert.strictEqual(list.consume(6, true), 'foobar');
assert.strictEqual(list.consume(6, true), 'foobar');
}

{
const list = new BufferList();
list.push('foo');
list.push('bar');
assert.strictEqual(list.consume(5, true), 'fooba');
}

{
const list = new BufferList();
list.push(buf);
list.push(buf);
list.push(buf);
list.push(buf);
assert.strictEqual(list.consume(6).toString(), 'foofoo');
assert.strictEqual(list.consume(6).toString(), 'foofoo');
}

{
const list = new BufferList();
list.push(buf);
list.push(buf);
assert.strictEqual(list.consume(5).toString(), 'foofo');
}

0 comments on commit 951a78b

Please sign in to comment.