From: Jérôme Benoit Date: Tue, 21 May 2024 20:50:12 +0000 (+0200) Subject: test: add circular buffer toArray() test X-Git-Tag: v4.0.12~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bad5c70587b40a86fa4f55390c84bcc88cc8cbbd;p=poolifier.git test: add circular buffer toArray() test Signed-off-by: Jérôme Benoit --- diff --git a/tests/circular-buffer.test.mjs b/tests/circular-buffer.test.mjs index ec86ca2a..804bb587 100644 --- a/tests/circular-buffer.test.mjs +++ b/tests/circular-buffer.test.mjs @@ -57,4 +57,15 @@ describe('Circular buffer test suite', t => { expect(circularBuffer.items).toMatchObject([5, 6, 3, 4]) expect(circularBuffer.writeIdx).toBe(2) }) + + it('Verify that circular buffer toArray() works as intended', () => { + const circularBuffer = new CircularBuffer(4) + circularBuffer.put(1) + circularBuffer.put(2) + circularBuffer.put(3) + circularBuffer.put(4) + circularBuffer.put(5) + circularBuffer.put(6) + expect(circularBuffer.toArray()).toStrictEqual([5, 6, 3, 4]) + }) })