Skip to content

Commit c485506

Browse files
committed
time: update TestSub to avoid future regressions
CL 131196 optimized Time.Sub, but was reverted because it incorrectly computed the nanoseconds in some edge cases. This CL adds a test case to enforce the correct behavior so that a future optimization does not break this again. Updates #17858 Updates #33677 Change-Id: I596d8302ca6bf721cf7ca11cc6f939639fcbdd43 Reviewed-on: https://go-review.googlesource.com/c/go/+/190524 Run-TryBot: Joe Tsai <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Reviewed-by: Andrew Bonventre <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent bb5441d commit c485506

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/time/time_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ var gobTests = []Time{
690690
Date(0, 1, 2, 3, 4, 5, 6, UTC),
691691
Date(7, 8, 9, 10, 11, 12, 13, FixedZone("", 0)),
692692
Unix(81985467080890095, 0x76543210), // Time.sec: 0x0123456789ABCDEF
693-
{}, // nil location
693+
{}, // nil location
694694
Date(1, 2, 3, 4, 5, 6, 7, FixedZone("", 32767*60)),
695695
Date(1, 2, 3, 4, 5, 6, 7, FixedZone("", -32768*60)),
696696
}
@@ -995,6 +995,7 @@ var subTests = []struct {
995995
{Date(2300, 1, 1, 0, 0, 0, 0, UTC), Date(2000, 1, 1, 0, 0, 0, 0, UTC), Duration(maxDuration)},
996996
{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},
997997
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2300, 1, 1, 0, 0, 0, 0, UTC), Duration(minDuration)},
998+
{Date(2311, 11, 26, 02, 16, 47, 63535996, UTC), Date(2019, 8, 16, 2, 29, 30, 268436582, UTC), 9223372036795099414},
998999
{MinMonoTime, MaxMonoTime, minDuration},
9991000
{MaxMonoTime, MinMonoTime, maxDuration},
10001001
}

0 commit comments

Comments
 (0)