time: replace time.Now().Sub call with time.Since in test

Signed-off-by: guoguangwu <guoguangwug@gmail.com>
This commit is contained in:
guoguangwu 2024-03-12 16:32:46 +08:00
parent 2ab9218c86
commit 686e02db77
1 changed files with 2 additions and 2 deletions

View 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)
}
@ -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) {