MCPcopy Index your code
hub / github.com/beevik/timerqueue / TestQueue

Function TestQueue

queue_test.go:59–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestQueue(t *testing.T) {
60 for iter := 0; iter < 100; iter++ {
61 now := time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)
62 queue := populateQueue(t, now)
63
64 // Make sure objects are removed from the queue in order.
65 for prev := now; queue.Len() > 0; {
66 _, ptm := queue.PeekFirst()
67 _, tm := queue.PopFirst()
68 if tm != ptm {
69 t.Errorf("Peek/Pop mismatch.\n")
70 }
71 if tm.Sub(prev) != time.Hour {
72 t.Errorf("Invalid queue ordering.\n"+
73 " Got: %v\n"+
74 "Expected: %v\n", tm, prev.Add(time.Hour))
75 }
76 prev = tm
77 }
78 }
79}
80
81func TestAdvance(t *testing.T) {
82 for iter := 0; iter < 100; iter++ {

Callers

nothing calls this directly

Calls 4

populateQueueFunction · 0.85
PeekFirstMethod · 0.80
PopFirstMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected