diff options
author | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
commit | 8528da672cc093d4dd06732819abc1f7b6b5a46e (patch) | |
tree | 334be80d4a4c85b77db6f6fdb67cbf0528cba5f5 /src/time/zoneinfo_test.go | |
parent | 73bcb69f272cbf34ddcc9daa56427a8683b5a95d (diff) | |
download | go-8528da672cc093d4dd06732819abc1f7b6b5a46e.tar.gz |
build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
Diffstat (limited to 'src/time/zoneinfo_test.go')
-rw-r--r-- | src/time/zoneinfo_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go new file mode 100644 index 000000000..4ca7fad93 --- /dev/null +++ b/src/time/zoneinfo_test.go @@ -0,0 +1,63 @@ +// 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" +) + +func TestVersion3(t *testing.T) { + time.ForceZipFileForTesting(true) + defer time.ForceZipFileForTesting(false) + _, err := time.LoadLocation("Asia/Jerusalem") + if err != nil { + t.Fatal(err) + } +} + +// 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) { + 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) + } + } +} |