Skip to content

Commit

Permalink
test: increase buffer list coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
emilsivervik committed Jan 6, 2021
1 parent 83ab543 commit f108d40
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 f108d40

Please sign in to comment.