Skip to content

Commit 64017d1

Browse files
testwillgopherbot
authored andcommitted
time: replace time.Now().Sub call with time.Since in test
Change-Id: I56ca2d11637d60c6b0656fdc1d900a2384aba141 GitHub-Last-Rev: 686e02d GitHub-Pull-Request: #66264 Reviewed-on: https://go-review.googlesource.com/c/go/+/570916 Reviewed-by: qiulaidongfeng <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 90a2dcf commit 64017d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/time/sleep_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestSleep(t *testing.T) {
6363
start := Now()
6464
Sleep(delay)
6565
delayadj := adjustDelay(t, delay)
66-
duration := Now().Sub(start)
66+
duration := Since(start)
6767
if duration < delayadj {
6868
t.Fatalf("Sleep(%s) slept for only %s", delay, duration)
6969
}
@@ -322,7 +322,7 @@ func TestAfter(t *testing.T) {
322322
start := Now()
323323
end := <-After(delay)
324324
delayadj := adjustDelay(t, delay)
325-
if duration := Now().Sub(start); duration < delayadj {
325+
if duration := Since(start); duration < delayadj {
326326
t.Fatalf("After(%s) slept for only %d ns", delay, duration)
327327
}
328328
if min := start.Add(delayadj); end.Before(min) {

0 commit comments

Comments
 (0)