mirror of
https://github.com/golang/sys.git
synced 2026-02-09 04:06:04 +03:00
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:
committed by
Tobias Klauser
parent
2f3576d2c5
commit
fee6b63275
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user