From d0293c6f223614f7d6a225d35e450650ef870f36 Mon Sep 17 00:00:00 2001 From: Geon Kim Date: Fri, 24 Feb 2023 23:07:38 +0900 Subject: [PATCH] time: add Time.ZoneBounds test cases for after non-DST last transition --- src/time/time_test.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/time/time_test.go b/src/time/time_test.go index 4221efec88..88da16de0c 100644 --- a/src/time/time_test.go +++ b/src/time/time_test.go @@ -18,6 +18,7 @@ import ( "sync" "testing" "testing/quick" + "time" . "time" ) @@ -1860,16 +1861,26 @@ func TestZoneBounds(t *testing.T) { 5: {Date(1991, September, 14, 17, 0, 0, 0, loc), boundTwo, boundThree}, 6: {Date(1991, September, 15, 0, 50, 0, 0, loc), boundTwo, boundThree}, + // The ZoneBounds of a "Asia/Shanghai" after the last transition (Standard Time) + 7: {boundThree, boundThree, time.Time{}}, + 8: {Date(1991, December, 15, 1, 50, 0, 0, loc), boundThree, time.Time{}}, + 9: {Date(1992, April, 13, 17, 50, 0, 0, loc), boundThree, time.Time{}}, + 10: {Date(1992, April, 13, 18, 0, 0, 0, loc), boundThree, time.Time{}}, + 11: {Date(1992, April, 14, 1, 50, 0, 0, loc), boundThree, time.Time{}}, + 12: {Date(1992, September, 14, 16, 50, 0, 0, loc), boundThree, time.Time{}}, + 13: {Date(1992, September, 14, 17, 0, 0, 0, loc), boundThree, time.Time{}}, + 14: {Date(1992, September, 15, 0, 50, 0, 0, loc), boundThree, time.Time{}}, + // The ZoneBounds of a local time would return two local Time. // Note: We preloaded "America/Los_Angeles" as time.Local for testing - 7: {makeLocalTime(0), makeLocalTime(-5756400), makeLocalTime(9972000)}, - 8: {makeLocalTime(1221681866), makeLocalTime(1205056800), makeLocalTime(1225616400)}, - 9: {makeLocalTime(2152173599), makeLocalTime(2145916800), makeLocalTime(2152173600)}, - 10: {makeLocalTime(2152173600), makeLocalTime(2152173600), makeLocalTime(2172733200)}, - 11: {makeLocalTime(2152173601), makeLocalTime(2152173600), makeLocalTime(2172733200)}, - 12: {makeLocalTime(2159200800), makeLocalTime(2152173600), makeLocalTime(2172733200)}, - 13: {makeLocalTime(2172733199), makeLocalTime(2152173600), makeLocalTime(2172733200)}, - 14: {makeLocalTime(2172733200), makeLocalTime(2172733200), makeLocalTime(2177452800)}, + 15: {makeLocalTime(0), makeLocalTime(-5756400), makeLocalTime(9972000)}, + 16: {makeLocalTime(1221681866), makeLocalTime(1205056800), makeLocalTime(1225616400)}, + 17: {makeLocalTime(2152173599), makeLocalTime(2145916800), makeLocalTime(2152173600)}, + 18: {makeLocalTime(2152173600), makeLocalTime(2152173600), makeLocalTime(2172733200)}, + 19: {makeLocalTime(2152173601), makeLocalTime(2152173600), makeLocalTime(2172733200)}, + 20: {makeLocalTime(2159200800), makeLocalTime(2152173600), makeLocalTime(2172733200)}, + 21: {makeLocalTime(2172733199), makeLocalTime(2152173600), makeLocalTime(2172733200)}, + 22: {makeLocalTime(2172733200), makeLocalTime(2172733200), makeLocalTime(2177452800)}, } for i, tt := range realTests { start, end := tt.giveTime.ZoneBounds()