summaryrefslogtreecommitdiff
path: root/pkg/priority_queue/binary_heap_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/priority_queue/binary_heap_test.go')
-rw-r--r--pkg/priority_queue/binary_heap_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/priority_queue/binary_heap_test.go b/pkg/priority_queue/binary_heap_test.go
index fb5b83de..456fc27e 100644
--- a/pkg/priority_queue/binary_heap_test.go
+++ b/pkg/priority_queue/binary_heap_test.go
@@ -61,6 +61,28 @@ func TestBinHeap_Init(t *testing.T) {
require.Equal(t, expected, res)
}
+func TestBinHeap_MaxLen(t *testing.T) {
+ a := []Item{Test(2), Test(23), Test(33), Test(44), Test(1), Test(2), Test(2), Test(2), Test(4), Test(6), Test(99)}
+
+ bh := NewBinHeap(1)
+
+ go func() {
+ expected := []Item{Test(1), Test(2), Test(2), Test(2), Test(2), Test(4), Test(6), Test(23), Test(33), Test(44), Test(99)}
+
+ res := make([]Item, 0, 12)
+
+ for i := 0; i < 11; i++ {
+ item := bh.ExtractMin()
+ res = append(res, item)
+ }
+ require.Equal(t, expected, res)
+ }()
+
+ for i := 0; i < len(a); i++ {
+ bh.Insert(a[i])
+ }
+}
+
func TestNewPriorityQueue(t *testing.T) {
insertsPerSec := uint64(0)
getPerSec := uint64(0)