Package list golang-gopkg-eapache-queue.v1 / 25134b6
basic tests Evan Huus 7 years ago
1 changed file(s) with 21 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
00 package queue
11
22 import "testing"
3
4 func TestQueueLength(t *testing.T) {
5 q := New()
6
7 if q.Length() != 0 {
8 t.Error("empty queue length not 0")
9 }
10
11 for i := 0; i < 1000; i++ {
12 q.Add(i)
13 if q.Length() != i+1 {
14 t.Error("adding: queue with", i , "elements has length", q.Length())
15 }
16 }
17 for i := 0; i < 1000; i++ {
18 q.Remove()
19 if q.Length() != 1000-i-1 {
20 t.Error("removing: queue with", 1000-i-i , "elements has length", q.Length())
21 }
22 }
23 }
324
425 // General warning: Go's benchmark utility (go test -bench .) increases the number of
526 // iterations until the benchmarks take a reasonable amount of time to run; memory usage