MCPcopy Index your code
hub / github.com/desertbit/timer / TestMultipleResets

Function TestMultipleResets

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

Source from the content-addressed store, hash-verified

219}
220
221func TestMultipleResets(t *testing.T) {
222 start := time.Now()
223 var timers []*Timer
224
225 for i := 0; i < 1000; i++ {
226 timer := NewTimer(time.Second)
227 timers = append(timers, timer)
228 timer.Reset(2 * time.Second)
229 }
230
231 // Wait for them all to expire.
232 for _, timer := range timers {
233 <-timer.C
234 }
235
236 if int(time.Since(start).Seconds()) != 2 {
237 t.Errorf("took ~%v seconds, should be ~2 seconds\n", int(time.Since(start).Seconds()))
238 }
239}
240
241func TestMultipleZeroResets(t *testing.T) {
242 start := time.Now()

Callers

nothing calls this directly

Calls 2

ResetMethod · 0.95
NewTimerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…