MCPcopy
hub / github.com/emirpasic/gods / TestQueueIteratorNext

Function TestQueueIteratorNext

queues/circularbuffer/circularbuffer_test.go:161–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func TestQueueIteratorNext(t *testing.T) {
162 queue := New(3)
163 queue.Enqueue("a")
164 queue.Enqueue("b")
165 queue.Enqueue("c")
166
167 it := queue.Iterator()
168 count := 0
169 for it.Next() {
170 count++
171 index := it.Index()
172 value := it.Value()
173 switch index {
174 case 0:
175 if actualValue, expectedValue := value, "a"; actualValue != expectedValue {
176 t.Errorf("Got %v expected %v", actualValue, expectedValue)
177 }
178 case 1:
179 if actualValue, expectedValue := value, "b"; actualValue != expectedValue {
180 t.Errorf("Got %v expected %v", actualValue, expectedValue)
181 }
182 case 2:
183 if actualValue, expectedValue := value, "c"; actualValue != expectedValue {
184 t.Errorf("Got %v expected %v", actualValue, expectedValue)
185 }
186 default:
187 t.Errorf("Too many")
188 }
189 if actualValue, expectedValue := index, count-1; actualValue != expectedValue {
190 t.Errorf("Got %v expected %v", actualValue, expectedValue)
191 }
192 }
193 if actualValue, expectedValue := count, 3; actualValue != expectedValue {
194 t.Errorf("Got %v expected %v", actualValue, expectedValue)
195 }
196
197 queue.Clear()
198 it = queue.Iterator()
199 for it.Next() {
200 t.Errorf("Shouldn't iterate on empty queue")
201 }
202}
203
204func TestQueueIteratorPrev(t *testing.T) {
205 queue := New(3)

Callers

nothing calls this directly

Calls 7

NewFunction · 0.70
EnqueueMethod · 0.65
NextMethod · 0.65
IndexMethod · 0.65
ValueMethod · 0.65
ClearMethod · 0.65
IteratorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…