-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrealtime_test.go
More file actions
42 lines (33 loc) · 846 Bytes
/
realtime_test.go
File metadata and controls
42 lines (33 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package abtime
import (
"testing"
"time"
)
// given the simplicity of the implementations here, there isn't much that
// can subtly go wrong, so this is mostly a coverage test, although, it's
// legit to at least ensure all functions are covered and don't crash.
func TestConcrete(t *testing.T) {
rt := NewRealTime()
rt.Now()
ch := rt.After(time.Nanosecond, 0)
<-ch
rt.Sleep(time.Nanosecond, 0)
ch = rt.Tick(time.Nanosecond, 0)
<-ch
<-ch
ticker := rt.NewTicker(time.Nanosecond, 0)
ticker.Channel()
ticker.Reset(time.Second)
ticker.Stop()
sendAfter := make(chan struct{})
rt.AfterFunc(time.Nanosecond, func() {
sendAfter <- struct{}{}
}, 0)
<-sendAfter
timer := rt.NewTimer(time.Nanosecond, 0)
if timer.Channel() == nil {
t.Fatal("Channel isn't working properly")
}
timer.Reset(time.Millisecond)
timer.Stop()
}