MCPcopy Create free account
hub / github.com/desertbit/timer / TestMultipleDifferentTimouts

Function TestMultipleDifferentTimouts

timer_test.go:75–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestMultipleDifferentTimouts(t *testing.T) {
76 start := time.Now()
77 var timers []*Timer
78
79 for i := 0; i < 1000; i++ {
80 timers = append(timers, NewTimer(time.Duration(i%4)*time.Second))
81 }
82
83 // Wait for them all to expire.
84 for _, timer := range timers {
85 <-timer.C
86 }
87
88 if int(time.Since(start).Seconds()) != 3 {
89 t.Errorf("took ~%v seconds, should be ~3 seconds\n", int(time.Since(start).Seconds()))
90 }
91}
92
93func TestStoppedTimer(t *testing.T) {
94 timer := NewStoppedTimer()

Callers

nothing calls this directly

Calls 1

NewTimerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…