forked from chen3feng/stl4go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlist_queue_test.go
90 lines (77 loc) · 1.76 KB
/
dlist_queue_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package stl4go
import (
"testing"
)
func Test_Queue_Interface(t *testing.T) {
q := NewDListQueue[int]()
_ = Deque[int](q)
}
func Test_Queue_New(t *testing.T) {
q := NewDListQueue[int]()
expectTrue(t, q.IsEmpty())
expectEq(t, q.Len(), 0)
}
func Test_Queue_Clear(t *testing.T) {
q := NewDListQueue[int]()
q.PushBack(1)
q.Clear()
expectTrue(t, q.IsEmpty())
expectEq(t, q.Len(), 0)
}
func Test_Queue_String(t *testing.T) {
q := NewDListQueue[int]()
expectEq(t, q.String(), "Queue[int]")
}
func Test_Queue_Front_Back(t *testing.T) {
q := NewDListQueue[int]()
expectPanic(t, func() { q.Front() })
expectPanic(t, func() { q.Back() })
q.PushBack(1)
q.PushBack(2)
expectEq(t, q.Front(), 1)
expectEq(t, q.Back(), 2)
}
func Test_Queue_PushFront(t *testing.T) {
q := NewDListQueue[int]()
q.PushFront(1)
expectFalse(t, q.IsEmpty())
expectEq(t, q.Len(), 1)
}
func Test_Queue_PushBack(t *testing.T) {
q := NewDListQueue[int]()
q.PushBack(1)
expectFalse(t, q.IsEmpty())
expectEq(t, q.Len(), 1)
}
func Test_Queue_TryPopFront(t *testing.T) {
q := NewDListQueue[int]()
_, ok := q.TryPopFront()
expectFalse(t, ok)
}
func Test_Queue_TryPopBack(t *testing.T) {
q := NewDListQueue[int]()
_, ok := q.TryPopBack()
expectFalse(t, ok)
}
func Test_Queue_PushFront_PopFront(t *testing.T) {
q := NewDListQueue[int]()
q.PushFront(1)
q.PushFront(2)
expectEq(t, q.PopFront(), 2)
expectEq(t, q.PopFront(), 1)
}
func Test_Queue_PushFront_PopBack(t *testing.T) {
q := NewDListQueue[int]()
q.PushFront(1)
expectEq(t, q.PopBack(), 1)
}
func Test_Queue_PushBack_PopFront(t *testing.T) {
q := NewDListQueue[int]()
q.PushBack(1)
expectEq(t, q.PopFront(), 1)
}
func Test_Queue_PushBack_PopBack(t *testing.T) {
q := NewDListQueue[int]()
q.PushBack(1)
expectEq(t, q.PopBack(), 1)
}