mirror of
https://github.com/golang/go
synced 2024-11-21 21:14:47 -07:00
encoding/asn1: fix test on OpenBSD
time.Parse uses time.Local if it has the right zone offset, otherwise it calls time.FixedZone. The test's use of reflect.DeepEqual meant that the test expected time.FixedZone always, failing when the local time zone really would have used -0700 for that time. The fix is to format the time to display only the pieces we intend to test. R=golang-dev, agl, iant CC=golang-dev https://golang.org/cl/5437088
This commit is contained in:
parent
12eee9edbc
commit
e812db3558
@ -223,13 +223,21 @@ var utcTestData = []timeTest{
|
|||||||
func TestUTCTime(t *testing.T) {
|
func TestUTCTime(t *testing.T) {
|
||||||
for i, test := range utcTestData {
|
for i, test := range utcTestData {
|
||||||
ret, err := parseUTCTime([]byte(test.in))
|
ret, err := parseUTCTime([]byte(test.in))
|
||||||
if (err == nil) != test.ok {
|
if err != nil {
|
||||||
t.Errorf("#%d: Incorrect error result (did fail? %v, expected: %v)", i, err == nil, test.ok)
|
if test.ok {
|
||||||
}
|
t.Errorf("#%d: parseUTCTime(%q) = error %v", i, err)
|
||||||
if err == nil {
|
|
||||||
if !reflect.DeepEqual(test.out, ret) {
|
|
||||||
t.Errorf("#%d: Bad result: %v (expected %v)", i, ret, test.out)
|
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !test.ok {
|
||||||
|
t.Errorf("#%d: parseUTCTime(%q) succeeded, should have failed", i)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const format = "Jan _2 15:04:05 -0700 2006" // ignore zone name, just offset
|
||||||
|
have := ret.Format(format)
|
||||||
|
want := test.out.Format(format)
|
||||||
|
if have != want {
|
||||||
|
t.Errorf("#%d: parseUTCTime(%q) = %s, want %s", test.in, have, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user