]> Cypherpunks repositories - gostls13.git/commitdiff
time: increase test coverage for Time.Sub
authortengufromsky <nick27surgut@gmail.com>
Sat, 14 Apr 2018 07:50:52 +0000 (10:50 +0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 16 Apr 2018 21:14:40 +0000 (21:14 +0000)
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>
src/time/internal_test.go
src/time/time_test.go

index 76d55241241dacc50bea742dff4da65ef6cc637c..336deb921122294f6819fe9448fcb5668e94fed4 100644 (file)
@@ -76,3 +76,8 @@ func CheckRuntimeTimerOverflow() {
        // So we fall back to hope: We hope we don't hang here.
        <-t.C
 }
+
+var (
+       MinMonoTime = Time{wall: 1 << 63, ext: -1 << 63, loc: UTC}
+       MaxMonoTime = Time{wall: 1 << 63, ext: 1<<63 - 1, loc: UTC}
+)
index cde99e2622c8148c355ee42a35f93bba846721f2..7778bf1f83b252abbf31b08ef700c3999457052a 100644 (file)
@@ -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(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)},
+       {MinMonoTime, MaxMonoTime, minDuration},
+       {MaxMonoTime, MinMonoTime, maxDuration},
 }
 
 func TestSub(t *testing.T) {