test: use correct size in test-stream-buffer-list
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: https://github.com/nodejs/node/pull/18239 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
80b3acca07
commit
2313424abc
@ -15,16 +15,21 @@ assert.strictEqual(emptyList.join(','), '');
|
|||||||
|
|
||||||
assert.deepStrictEqual(emptyList.concat(0), Buffer.alloc(0));
|
assert.deepStrictEqual(emptyList.concat(0), Buffer.alloc(0));
|
||||||
|
|
||||||
|
const buf = Buffer.from('foo');
|
||||||
|
|
||||||
// Test buffer list with one element.
|
// Test buffer list with one element.
|
||||||
const list = new BufferList();
|
const list = new BufferList();
|
||||||
list.push('foo');
|
list.push(buf);
|
||||||
|
|
||||||
assert.strictEqual(list.concat(1), 'foo');
|
const copy = list.concat(3);
|
||||||
|
|
||||||
|
assert.notStrictEqual(copy, buf);
|
||||||
|
assert.deepStrictEqual(copy, buf);
|
||||||
|
|
||||||
assert.strictEqual(list.join(','), 'foo');
|
assert.strictEqual(list.join(','), 'foo');
|
||||||
|
|
||||||
const shifted = list.shift();
|
const shifted = list.shift();
|
||||||
assert.strictEqual(shifted, 'foo');
|
assert.strictEqual(shifted, buf);
|
||||||
assert.deepStrictEqual(list, new BufferList());
|
assert.deepStrictEqual(list, new BufferList());
|
||||||
|
|
||||||
const tmp = util.inspect.defaultOptions.colors;
|
const tmp = util.inspect.defaultOptions.colors;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user