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

Function TestMultipleStop

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

Source from the content-addressed store, hash-verified

140}
141
142func TestMultipleStop(t *testing.T) {
143 var timers []*Timer
144
145 for i := 0; i < 1000; i++ {
146 timer := NewTimer(time.Second)
147 wasActive := timer.Stop()
148 if !wasActive {
149 t.Errorf("stop timer: was active is false")
150 }
151
152 timers = append(timers, timer)
153 }
154
155 time.Sleep(2 * time.Second)
156
157 // All channels must block.
158 for _, timer := range timers {
159 select {
160 case <-timer.C:
161 t.Errorf("failed to stop timer")
162 default:
163 }
164 }
165
166 for _, timer := range timers {
167 wasActive := timer.Stop()
168 if wasActive {
169 t.Errorf("stop timer: was active is true")
170 }
171 }
172}
173
174func TestReset(t *testing.T) {
175 start := time.Now()

Callers

nothing calls this directly

Calls 2

StopMethod · 0.95
NewTimerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…