From f108d40fb97888a67b204676cf9d76f23ebdc305 Mon Sep 17 00:00:00 2001 From: Emil Sivervik Date: Wed, 30 Dec 2020 13:55:36 +0100 Subject: [PATCH] test: increase buffer list coverage 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 --- test/parallel/test-stream-buffer-list.js | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/parallel/test-stream-buffer-list.js b/test/parallel/test-stream-buffer-list.js index 5b495a41e08545..d9d0405f4d5a45 100644 --- a/test/parallel/test-stream-buffer-list.js +++ b/test/parallel/test-stream-buffer-list.js @@ -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'); +}