| 219 | } |
| 220 | |
| 221 | func 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 | |
| 241 | func TestMultipleZeroResets(t *testing.T) { |
| 242 | start := time.Now() |