-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpriorityq_test.go
50 lines (44 loc) · 956 Bytes
/
priorityq_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package ds
import (
_ "fmt"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestPriorityQueue(t *testing.T) {
pq := PriorityQ{}
pq.Init()
Convey("Test PQ", t, func() {
pq.PushWithPriority("a", -3)
pq.PushWithPriority("d", 1)
pq.PushWithPriority("c", 0.0)
pq.PushWithPriority("b", -1)
pq.PushWithPriority("e", 3)
v := pq.Pop()
So(v, ShouldEqual, "a")
v = pq.Pop()
So(v, ShouldEqual, "b")
v = pq.Pop()
So(v, ShouldEqual, "c")
v = pq.Pop()
So(v, ShouldEqual, "d")
v = pq.Pop()
So(v, ShouldEqual, "e")
})
Convey("Test PQ2", t, func() {
pq.PushWithPriority("b", -1)
pq.PushWithPriority("a", -3)
pq.PushWithPriority("e", 3)
pq.PushWithPriority("d", 1)
pq.PushWithPriority("c", 0.0)
v := pq.Pop()
So(v, ShouldEqual, "a")
v = pq.Pop()
So(v, ShouldEqual, "b")
v = pq.Pop()
So(v, ShouldEqual, "c")
v = pq.Pop()
So(v, ShouldEqual, "d")
v = pq.Pop()
So(v, ShouldEqual, "e")
})
}