mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-15 15:10:49 +00:00
28 lines
547 B
Go
28 lines
547 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"container/heap"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/go-playground/assert/v2"
|
||
|
)
|
||
|
|
||
|
func TestPriorityQueue(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
pq := newPriorityQueue()
|
||
|
|
||
|
heap.Push(pq, newNode(30, 0, 0, 0, 0, 0))
|
||
|
heap.Push(pq, newNode(10, 0, 0, 0, 8, 0))
|
||
|
heap.Push(pq, newNode(20, 0, 0, 0, 13, 0))
|
||
|
|
||
|
t.Run("Should create a queue size 3", func(t *testing.T) {
|
||
|
assert.Equal(t, 3, pq.Len())
|
||
|
})
|
||
|
|
||
|
item := heap.Pop(pq).(*node)
|
||
|
|
||
|
t.Run("Should return item with cost 10", func(t *testing.T) {
|
||
|
assert.Equal(t, 10, item.cost)
|
||
|
})
|
||
|
}
|