]> Cypherpunks repositories - gostls13.git/commitdiff
time: replace time.Now().Sub call with time.Since in test
authorguoguangwu <guoguangwug@gmail.com>
Wed, 13 Mar 2024 01:52:03 +0000 (01:52 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 14 Mar 2024 16:32:52 +0000 (16:32 +0000)
Change-Id: I56ca2d11637d60c6b0656fdc1d900a2384aba141
GitHub-Last-Rev: 686e02db77797fd81aafcde8ae40c85cee8dd817
GitHub-Pull-Request: golang/go#66264
Reviewed-on: https://go-review.googlesource.com/c/go/+/570916
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/time/sleep_test.go

index 8c28b1e4a922ab2888348dc25bc0423486506d2d..634a5c7a130d4d96307e9b387a8df3567b1b2c4a 100644 (file)
@@ -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)
        }
@@ -322,7 +322,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) {