test: improve priority queue coverage
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 20 Jun 2024 11:48:55 +0000 (13:48 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 20 Jun 2024 11:48:55 +0000 (13:48 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/priority-queue.test.mjs

index 80f580d15f88f8f1e811e0acd84baa13f6204138..d65d6f1656fffb8229d158ca6577ef77208c3471 100644 (file)
@@ -247,6 +247,7 @@ describe('Priority queue test suite', () => {
     expect(priorityQueue.maxSize).toBe(6)
     expect(priorityQueue.tail.empty()).toBe(false)
     expect(priorityQueue.tail.next).toBeInstanceOf(FixedPriorityQueue)
+    expect(priorityQueue.tail).not.toStrictEqual(priorityQueue.head)
     let rtItem = priorityQueue.dequeue(3)
     expect(priorityQueue.buckets).toBe(2)
     expect(priorityQueue.size).toBe(5)
@@ -254,6 +255,7 @@ describe('Priority queue test suite', () => {
     expect(rtItem).toBe(3)
     expect(priorityQueue.tail.empty()).toBe(false)
     expect(priorityQueue.tail.next).toBeInstanceOf(FixedPriorityQueue)
+    expect(priorityQueue.tail).not.toStrictEqual(priorityQueue.head)
     rtItem = priorityQueue.dequeue()
     expect(priorityQueue.buckets).toBe(2)
     expect(priorityQueue.size).toBe(4)
@@ -261,6 +263,7 @@ describe('Priority queue test suite', () => {
     expect(rtItem).toBe(1)
     expect(priorityQueue.tail.empty()).toBe(false)
     expect(priorityQueue.tail.next).toBeInstanceOf(FixedPriorityQueue)
+    expect(priorityQueue.tail).not.toStrictEqual(priorityQueue.head)
     rtItem = priorityQueue.dequeue(2)
     expect(priorityQueue.buckets).toBe(1)
     expect(priorityQueue.size).toBe(3)
@@ -268,6 +271,7 @@ describe('Priority queue test suite', () => {
     expect(rtItem).toBe(3)
     expect(priorityQueue.tail.empty()).toBe(false)
     expect(priorityQueue.tail.next).toBeInstanceOf(FixedPriorityQueue)
+    expect(priorityQueue.tail).not.toStrictEqual(priorityQueue.head)
     rtItem = priorityQueue.dequeue(2)
     expect(priorityQueue.buckets).toBe(1)
     expect(priorityQueue.size).toBe(2)
@@ -275,6 +279,7 @@ describe('Priority queue test suite', () => {
     expect(rtItem).toBe(3)
     expect(priorityQueue.tail.empty()).toBe(false)
     expect(priorityQueue.tail.next).toBeInstanceOf(FixedPriorityQueue)
+    expect(priorityQueue.tail).not.toStrictEqual(priorityQueue.head)
     rtItem = priorityQueue.dequeue(2)
     expect(priorityQueue.buckets).toBe(0)
     expect(priorityQueue.size).toBe(1)
@@ -282,6 +287,7 @@ describe('Priority queue test suite', () => {
     expect(rtItem).toBe(1)
     expect(priorityQueue.tail.empty()).toBe(false)
     expect(priorityQueue.tail.next).toBe(undefined)
+    expect(priorityQueue.tail).toStrictEqual(priorityQueue.head)
     rtItem = priorityQueue.dequeue()
     expect(priorityQueue.buckets).toBe(0)
     expect(priorityQueue.size).toBe(0)
@@ -289,6 +295,7 @@ describe('Priority queue test suite', () => {
     expect(rtItem).toBe(2)
     expect(priorityQueue.tail.empty()).toBe(true)
     expect(priorityQueue.tail.next).toBe(undefined)
+    expect(priorityQueue.tail).toStrictEqual(priorityQueue.head)
   })
 
   it('Verify enablePriority setter behavior', () => {