mirror of
https://github.com/golang/go
synced 2024-11-05 11:46:12 -07:00
time: increase test coverage for Time.Sub
Existing tests don't check overflow and underflow case for subtraction monotonic time. Updates #17858 Change-Id: I95311440134c92eadd7d5e409a0fc7c689e9bf41 Reviewed-on: https://go-review.googlesource.com/107056 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
224f807e26
commit
1670921a07
@ -76,3 +76,8 @@ func CheckRuntimeTimerOverflow() {
|
|||||||
// So we fall back to hope: We hope we don't hang here.
|
// So we fall back to hope: We hope we don't hang here.
|
||||||
<-t.C
|
<-t.C
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
MinMonoTime = Time{wall: 1 << 63, ext: -1 << 63, loc: UTC}
|
||||||
|
MaxMonoTime = Time{wall: 1 << 63, ext: 1<<63 - 1, loc: UTC}
|
||||||
|
)
|
||||||
|
@ -978,6 +978,8 @@ var subTests = []struct {
|
|||||||
{Date(2300, 1, 1, 0, 0, 0, 0, UTC), Date(2000, 1, 1, 0, 0, 0, 0, UTC), Duration(maxDuration)},
|
{Date(2300, 1, 1, 0, 0, 0, 0, UTC), Date(2000, 1, 1, 0, 0, 0, 0, UTC), Duration(maxDuration)},
|
||||||
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2290, 1, 1, 0, 0, 0, 0, UTC), -290*365*24*Hour - 71*24*Hour},
|
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2290, 1, 1, 0, 0, 0, 0, UTC), -290*365*24*Hour - 71*24*Hour},
|
||||||
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2300, 1, 1, 0, 0, 0, 0, UTC), Duration(minDuration)},
|
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2300, 1, 1, 0, 0, 0, 0, UTC), Duration(minDuration)},
|
||||||
|
{MinMonoTime, MaxMonoTime, minDuration},
|
||||||
|
{MaxMonoTime, MinMonoTime, maxDuration},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSub(t *testing.T) {
|
func TestSub(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user