summaryrefslogtreecommitdiff
path: root/pkg/priority_queue
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-13 15:40:57 +0300
committerGitHub <[email protected]>2021-09-13 15:40:57 +0300
commit5d2cd55ab522d4f1e65a833f91146444465a32ac (patch)
treea374c8e90383d5e868ffe6b44555a55029c54f79 /pkg/priority_queue
parentfe72d84395970281fe330a2b9423f8c0e4c3b9c8 (diff)
parentb8a4b82f82e2cb9f9efc4a3601a97b4ff07fefc7 (diff)
[#793]: fix(plugins): incorrect parsing local and global drivers sections
[#793]: fix(plugins): incorrect parsing local and global drivers sections
Diffstat (limited to 'pkg/priority_queue')
-rw-r--r--pkg/priority_queue/binary_heap_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/priority_queue/binary_heap_test.go b/pkg/priority_queue/binary_heap_test.go
index fb5b83de..ab0f9266 100644
--- a/pkg/priority_queue/binary_heap_test.go
+++ b/pkg/priority_queue/binary_heap_test.go
@@ -61,6 +61,32 @@ 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(2), Test(23), Test(33), Test(44), Test(1), Test(2), Test(2), Test(2), Test(4), Test(6), 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)
+ return
+ }()
+
+ time.Sleep(time.Second)
+ for i := 0; i < len(a); i++ {
+ bh.Insert(a[i])
+ }
+
+ time.Sleep(time.Second)
+}
+
func TestNewPriorityQueue(t *testing.T) {
insertsPerSec := uint64(0)
getPerSec := uint64(0)