-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfigo_test.go
165 lines (132 loc) · 2.44 KB
/
figo_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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package figo
import "testing"
func TestNew(t *testing.T) {
_ = New()
}
func Test_CanPush(t *testing.T) {
q := New()
q.Push("Nada")
}
func Test_CanPop(t *testing.T) {
q := New()
_ = q.Pop()
}
func Test_CanIsEmpty(t *testing.T) {
q := New()
_ = q.IsEmpty()
}
func Test_CanLen(t *testing.T) {
q := New()
_ = q.Len()
}
func Test_CanAddOneItem(t *testing.T) {
q := New()
if q.Len() != 0 {
t.Error("Didn't get the right size")
}
q.Push("Nada")
if q.Len() != 1 {
t.Error("Should have increased in size")
}
val := q.Pop()
if val != "Nada" {
t.Error("Did not get the correct value")
}
if q.Len() != 0 {
t.Error("Should have decreased in size")
}
}
func Test_CanAddMultipleItems(t *testing.T) {
q := New()
for i := 0; i < 10; i++ {
q.Push(i)
}
if q.IsEmpty() {
t.Error("The queue should not be empty")
}
for i := 0; !q.IsEmpty(); i++ {
v := q.Pop()
if v != i {
t.Error("Did not get the correct value")
}
}
}
func Test_CanIterateEmptyList(t *testing.T) {
q := New()
i := 0
for elem := q.Front(); q.Next(elem) != nil; elem = q.Next(elem) {
}
if i != 0 {
t.Error("Should have been empty")
return
}
}
func Test_CanIterateItems(t *testing.T) {
q := New()
for i := 0; i < 10; i++ {
q.Push(i)
}
i := 0
for elem := q.Front(); q.Next(elem) != nil; elem = q.Next(elem) {
if elem.Value.(int) != i {
t.Error("Did not match the correct order")
return
}
i++
}
if i != 9 {
t.Error("Did not iterate the whole list")
return
}
}
func TestAsync(t *testing.T) {
_ = NewAsync()
}
func TestAsync_CanPush(t *testing.T) {
q := NewAsync()
q.Push("Nada")
}
func TestAsync_CanPop(t *testing.T) {
q := NewAsync()
_ = q.Pop()
}
func TestAsync_CanIsEmpty(t *testing.T) {
q := NewAsync()
_ = q.IsEmpty()
}
func TestAsync_CanLen(t *testing.T) {
q := NewAsync()
_ = q.Len()
}
func TestAsync_CanAddOneItem(t *testing.T) {
q := NewAsync()
if q.Len() != 0 {
t.Error("Didn't get the right size")
}
q.Push("Nada")
if q.Len() != 1 {
t.Error("Should have increased in size")
}
val := q.Pop()
if val != "Nada" {
t.Error("Did not get the correct value")
}
if q.Len() != 0 {
t.Error("Should have decreased in size")
}
}
func TestAsync_CanAddMultipleItems(t *testing.T) {
q := NewAsync()
for i := 0; i < 10; i++ {
q.Push(i)
}
if q.IsEmpty() {
t.Error("The queue should not be empty")
}
for i := 0; !q.IsEmpty(); i++ {
v := q.Pop()
if v != i {
t.Error("Did not get the correct value")
}
}
}