summaryrefslogtreecommitdiff
path: root/libgo/go/time/zoneinfo_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-09-06 18:12:46 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-09-06 18:12:46 +0000
commitaa8901e9bb0399d2c16f988ba2fe46eb0c0c5d13 (patch)
tree7e63b06d1eec92beec6997c9d3ab47a5d6a835be /libgo/go/time/zoneinfo_test.go
parent920ea3b8ba3164b61ac9490dfdfceb6936eda6dd (diff)
libgo: update to Go 1.13beta1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/193497 From-SVN: r275473
Diffstat (limited to 'libgo/go/time/zoneinfo_test.go')
-rw-r--r--libgo/go/time/zoneinfo_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/libgo/go/time/zoneinfo_test.go b/libgo/go/time/zoneinfo_test.go
index 2f7612d018f..9ef64def104 100644
--- a/libgo/go/time/zoneinfo_test.go
+++ b/libgo/go/time/zoneinfo_test.go
@@ -157,3 +157,34 @@ func TestLoadLocationFromTZData(t *testing.T) {
t.Errorf("return values of LoadLocationFromTZData and LoadLocation don't match")
}
}
+
+// Issue 30099.
+func TestEarlyLocation(t *testing.T) {
+ t.Skip("gccgo does not use the zip file")
+ time.ForceZipFileForTesting(true)
+ defer time.ForceZipFileForTesting(false)
+
+ const locName = "America/New_York"
+ loc, err := time.LoadLocation(locName)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ d := time.Date(1900, time.January, 1, 0, 0, 0, 0, loc)
+ tzName, tzOffset := d.Zone()
+ if want := "EST"; tzName != want {
+ t.Errorf("Zone name == %s, want %s", tzName, want)
+ }
+ if want := -18000; tzOffset != want {
+ t.Errorf("Zone offset == %d, want %d", tzOffset, want)
+ }
+}
+
+func TestMalformedTZData(t *testing.T) {
+ // The goal here is just that malformed tzdata results in an error, not a panic.
+ issue29437 := "TZif\x00000000000000000\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0000"
+ _, err := time.LoadLocationFromTZData("abc", []byte(issue29437))
+ if err == nil {
+ t.Error("expected error, got none")
+ }
+}