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

Function TestStoppedTimer

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

Source from the content-addressed store, hash-verified

91}
92
93func TestStoppedTimer(t *testing.T) {
94 timer := NewStoppedTimer()
95 if !timer.when.IsZero() {
96 t.Errorf("invalid stopped timer when value")
97 }
98
99 start := time.Now()
100 wasActive := timer.Reset(time.Second)
101 if wasActive {
102 t.Errorf("stopped timer: was active is true")
103 }
104
105 <-timer.C
106 if int(time.Since(start).Seconds()) != 1 {
107 t.Errorf("took ~%v seconds, should be ~1 seconds\n", int(time.Since(start).Seconds()))
108 }
109}
110
111func TestStop(t *testing.T) {
112 timer := NewTimer(time.Second)

Callers

nothing calls this directly

Calls 2

NewStoppedTimerFunction · 0.85
ResetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…