mirror of https://github.com/golang/go.git
time: replace time.Now().Sub call with time.Since in test
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
This commit is contained in:
parent
2ab9218c86
commit
686e02db77
|
|
@ -63,7 +63,7 @@ func TestSleep(t *testing.T) {
|
|||
start := Now()
|
||||
Sleep(delay)
|
||||
delayadj := adjustDelay(t, delay)
|
||||
duration := Now().Sub(start)
|
||||
duration := Since(start)
|
||||
if duration < delayadj {
|
||||
t.Fatalf("Sleep(%s) slept for only %s", delay, duration)
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ func TestAfter(t *testing.T) {
|
|||
start := Now()
|
||||
end := <-After(delay)
|
||||
delayadj := adjustDelay(t, delay)
|
||||
if duration := Now().Sub(start); duration < delayadj {
|
||||
if duration := Since(start); duration < delayadj {
|
||||
t.Fatalf("After(%s) slept for only %d ns", delay, duration)
|
||||
}
|
||||
if min := start.Add(delayadj); end.Before(min) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue