summaryrefslogtreecommitdiffstats
path: root/libgo/go/time/tick_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/time/tick_test.go')
-rw-r--r--libgo/go/time/tick_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/libgo/go/time/tick_test.go b/libgo/go/time/tick_test.go
index 4dcb63956b2..36349349ce0 100644
--- a/libgo/go/time/tick_test.go
+++ b/libgo/go/time/tick_test.go
@@ -11,21 +11,21 @@ import (
func TestTicker(t *testing.T) {
const (
- Delta = 100 * 1e6
+ Delta = 100 * Millisecond
Count = 10
)
ticker := NewTicker(Delta)
- t0 := Nanoseconds()
+ t0 := Now()
for i := 0; i < Count; i++ {
<-ticker.C
}
ticker.Stop()
- t1 := Nanoseconds()
- ns := t1 - t0
- target := int64(Delta * Count)
+ t1 := Now()
+ dt := t1.Sub(t0)
+ target := Delta * Count
slop := target * 2 / 10
- if ns < target-slop || ns > target+slop {
- t.Fatalf("%d ticks of %g ns took %g ns, expected %g", Count, float64(Delta), float64(ns), float64(target))
+ if dt < target-slop || dt > target+slop {
+ t.Fatalf("%d %s ticks took %s, expected [%s,%s]", Count, Delta, dt, target-slop, target+slop)
}
// Now test that the ticker stopped
Sleep(2 * Delta)
OpenPOWER on IntegriCloud