unix: accept time.Now()±1 as valid in TestTime

Fixes golang/go#33200

Change-Id: I7e6e62f09174f0b214e7d021a31f1ad2166f9db5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/206861
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Tobias Klauser
2019-11-13 10:39:24 +01:00
committed by Tobias Klauser
parent 2f3576d2c5
commit fee6b63275
2 changed files with 6 additions and 6 deletions

View File

@@ -49,13 +49,13 @@ func TestTime(t *testing.T) {
}
now = time.Now()
if int64(ut) == now.Unix() {
diff := int64(ut) - now.Unix()
if -1 <= diff && diff <= 1 {
return
}
}
t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v", ut, now.Unix())
t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v±1", ut, now.Unix())
}
func TestUtime(t *testing.T) {

View File

@@ -125,13 +125,13 @@ func TestTime(t *testing.T) {
}
now = time.Now()
if int64(ut) == now.Unix() {
diff := int64(ut) - now.Unix()
if -1 <= diff && diff <= 1 {
return
}
}
t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v", ut, now.Unix())
t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v±1", ut, now.Unix())
}
func TestUtime(t *testing.T) {