github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/third_party/gofrontend/libgo/go/time/zoneinfo_test.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package time_test 6 7 import ( 8 "testing" 9 "time" 10 ) 11 12 func TestVersion3(t *testing.T) { 13 t.Skip("gccgo does not use the zip file") 14 time.ForceZipFileForTesting(true) 15 defer time.ForceZipFileForTesting(false) 16 _, err := time.LoadLocation("Asia/Jerusalem") 17 if err != nil { 18 t.Fatal(err) 19 } 20 } 21 22 // Test that we get the correct results for times before the first 23 // transition time. To do this we explicitly check early dates in a 24 // couple of specific timezones. 25 func TestFirstZone(t *testing.T) { 26 t.Skip("gccgo does not use the zip file") 27 28 time.ForceZipFileForTesting(true) 29 defer time.ForceZipFileForTesting(false) 30 31 const format = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)" 32 var tests = []struct { 33 zone string 34 unix int64 35 want1 string 36 want2 string 37 }{ 38 { 39 "PST8PDT", 40 -1633269601, 41 "Sun, 31 Mar 1918 01:59:59 -0800 (PST)", 42 "Sun, 31 Mar 1918 03:00:00 -0700 (PDT)", 43 }, 44 { 45 "Pacific/Fakaofo", 46 1325242799, 47 "Thu, 29 Dec 2011 23:59:59 -1100 (TKT)", 48 "Sat, 31 Dec 2011 00:00:00 +1300 (TKT)", 49 }, 50 } 51 52 for _, test := range tests { 53 z, err := time.LoadLocation(test.zone) 54 if err != nil { 55 t.Fatal(err) 56 } 57 s := time.Unix(test.unix, 0).In(z).Format(format) 58 if s != test.want1 { 59 t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want1) 60 } 61 s = time.Unix(test.unix+1, 0).In(z).Format(format) 62 if s != test.want2 { 63 t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want2) 64 } 65 } 66 }