diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-06-06 22:37:27 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-06-06 22:37:27 +0000 |
commit | 6736ef96eab222e58e6294f42be981a5afb59811 (patch) | |
tree | 2bc668fae9bf96f9a3988e0b0a16685bde8c4f0b /libgo/go/time/zoneinfo_test.go | |
parent | 38a138411da4206c53f9a153ee9c3624fce58a52 (diff) | |
download | gcc-6736ef96eab222e58e6294f42be981a5afb59811.zip gcc-6736ef96eab222e58e6294f42be981a5afb59811.tar.gz gcc-6736ef96eab222e58e6294f42be981a5afb59811.tar.bz2 |
libgo: Merge to master revision 19184.
The next revision, 19185, renames several runtime files, and
will be handled in a separate change.
From-SVN: r211328
Diffstat (limited to 'libgo/go/time/zoneinfo_test.go')
-rw-r--r-- | libgo/go/time/zoneinfo_test.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/libgo/go/time/zoneinfo_test.go b/libgo/go/time/zoneinfo_test.go new file mode 100644 index 0000000..03f54a6 --- /dev/null +++ b/libgo/go/time/zoneinfo_test.go @@ -0,0 +1,56 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package time_test + +import ( + "testing" + "time" +) + +// Test that we get the correct results for times before the first +// transition time. To do this we explicitly check early dates in a +// couple of specific timezones. +func TestFirstZone(t *testing.T) { + t.Skip("gccgo does not use the zip file") + + time.ForceZipFileForTesting(true) + defer time.ForceZipFileForTesting(false) + + const format = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)" + var tests = []struct { + zone string + unix int64 + want1 string + want2 string + }{ + { + "PST8PDT", + -1633269601, + "Sun, 31 Mar 1918 01:59:59 -0800 (PST)", + "Sun, 31 Mar 1918 03:00:00 -0700 (PDT)", + }, + { + "Pacific/Fakaofo", + 1325242799, + "Thu, 29 Dec 2011 23:59:59 -1100 (TKT)", + "Sat, 31 Dec 2011 00:00:00 +1300 (TKT)", + }, + } + + for _, test := range tests { + z, err := time.LoadLocation(test.zone) + if err != nil { + t.Fatal(err) + } + s := time.Unix(test.unix, 0).In(z).Format(format) + if s != test.want1 { + t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want1) + } + s = time.Unix(test.unix+1, 0).In(z).Format(format) + if s != test.want2 { + t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want2) + } + } +} |