package-rebuilds/pkgs/node-undici/node-undici-5.28.4+dfsg1+~cs23.12.11/test/fixed-queue.js
Fabian Grünbichler afee63929c add node-undici for libgit2 1.8.1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-09-10 11:23:24 +02:00

39 lines
783 B
JavaScript

'use strict'
const { test } = require('tap')
const FixedQueue = require('../lib/node/fixed-queue')
test('fixed queue 1', (t) => {
t.plan(5)
const queue = new FixedQueue()
t.equal(queue.head, queue.tail)
t.ok(queue.isEmpty())
queue.push('a')
t.ok(!queue.isEmpty())
t.equal(queue.shift(), 'a')
t.equal(queue.shift(), null)
})
test('fixed queue 2', (t) => {
t.plan(7 + 2047)
const queue = new FixedQueue()
for (let i = 0; i < 2047; i++) {
queue.push('a')
}
t.ok(queue.head.isFull())
queue.push('a')
t.ok(!queue.head.isFull())
t.not(queue.head, queue.tail)
for (let i = 0; i < 2047; i++) {
t.equal(queue.shift(), 'a')
}
t.equal(queue.head, queue.tail)
t.ok(!queue.isEmpty())
t.equal(queue.shift(), 'a')
t.ok(queue.isEmpty())
})