(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestNewAfterTimer(t *testing.T) { |
| 69 | var exists = struct { |
| 70 | timers int |
| 71 | createdTimes int |
| 72 | closingTimers int |
| 73 | }{ |
| 74 | timers: len(timerManager.timers), |
| 75 | createdTimes: len(timerManager.createdTimer), |
| 76 | closingTimers: len(timerManager.closingTimer), |
| 77 | } |
| 78 | |
| 79 | const tc = 1000 |
| 80 | var counter int64 |
| 81 | for i := 0; i < tc; i++ { |
| 82 | NewAfterTimer(1*time.Millisecond, func() { |
| 83 | atomic.AddInt64(&counter, 1) |
| 84 | }) |
| 85 | } |
| 86 | |
| 87 | <-time.After(5 * time.Millisecond) |
| 88 | cron() |
| 89 | if counter != tc { |
| 90 | t.Fatalf("expect: %d, got: %d", tc, counter) |
| 91 | } |
| 92 | |
| 93 | if len(timerManager.timers) != exists.timers { |
| 94 | t.Fatalf("timers: %d", len(timerManager.timers)) |
| 95 | } |
| 96 | |
| 97 | if len(timerManager.createdTimer) != exists.createdTimes { |
| 98 | t.Fatalf("createdTimer: %d", len(timerManager.createdTimer)) |
| 99 | } |
| 100 | |
| 101 | if len(timerManager.closingTimer) != exists.closingTimers { |
| 102 | t.Fatalf("closingTimer: %d", len(timerManager.closingTimer)) |
| 103 | } |
| 104 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…