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.

PR-URL: #18239
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
lpinca committed Jan 24, 2018
1 parent 80b3acc commit 2313424
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 @@ -15,16 +15,21 @@ 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());

const tmp = util.inspect.defaultOptions.colors;
Expand Down

0 comments on commit 2313424

Please sign in to comment.