Package list golang-gopkg-eapache-queue.v1 / 5a1f0d3
Two more tests, just for completeness's sake Evan Huus 7 years ago
1 changed file(s) with 33 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
00 package queue
11
22 import "testing"
3
4 func TestQueueSimple(t *testing.T) {
5 q := New()
6
7 for i := 0; i < minQueueLen; i++ {
8 q.Add(i)
9 }
10 for i := 0; i < minQueueLen; i++ {
11 if q.Peek().(int) != i {
12 t.Error("peek", i, "had value", q.Peek())
13 }
14 q.Remove()
15 }
16 }
17
18 func TestQueueWrapping(t *testing.T) {
19 q := New()
20
21 for i := 0; i < minQueueLen; i++ {
22 q.Add(i)
23 }
24 for i := 0; i < 3; i++ {
25 q.Remove()
26 q.Add(minQueueLen + i)
27 }
28
29 for i := 0; i < minQueueLen; i++ {
30 if q.Peek().(int) != i+3 {
31 t.Error("peek", i, "had value", q.Peek())
32 }
33 q.Remove()
34 }
35 }
336
437 func TestQueueLength(t *testing.T) {
538 q := New()