Skip to content

Commit

Permalink
test: use correct size in test-stream-buffer-list
Browse files Browse the repository at this point in the history
The `n` argument of `BufferList.prototype.concat()` is not the number
of `Buffer` instances in the list, but their total length when
concatenated.

Backport-PR-URL: #19483
PR-URL: #18239
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
lpinca authored and MylesBorins committed Mar 21, 2018
1 parent cb0f658 commit 708931d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/parallel/test-stream-buffer-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ assert.strictEqual(emptyList.join(','), '');

assert.deepStrictEqual(emptyList.concat(0), Buffer.alloc(0));

const buf = Buffer.from('foo');

// Test buffer list with one element.
const list = new BufferList();
list.push('foo');
list.push(buf);

const copy = list.concat(3);

assert.strictEqual(list.concat(1), 'foo');
assert.notStrictEqual(copy, buf);
assert.deepStrictEqual(copy, buf);

assert.strictEqual(list.join(','), 'foo');

const shifted = list.shift();
assert.strictEqual(shifted, 'foo');
assert.strictEqual(shifted, buf);
assert.deepStrictEqual(list, new BufferList());

0 comments on commit 708931d

Please sign in to comment.