aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-11-30 13:36:25 -0500
committerRuss Cox <rsc@golang.org>2011-11-30 13:36:25 -0500
commite812db35581d257fb2d3518509898fc22bdd2d48 (patch)
tree104305c26a49ead851aff1dc9e1be038c24aeb84
parent12eee9edbc0a63ba5802541ec9bfec4a925637ee (diff)
downloadgo-e812db35581d257fb2d3518509898fc22bdd2d48.tar.gz
go-e812db35581d257fb2d3518509898fc22bdd2d48.zip
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
-rw-r--r--src/pkg/encoding/asn1/asn1_test.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/pkg/encoding/asn1/asn1_test.go b/src/pkg/encoding/asn1/asn1_test.go
index ea1906a7b6..2e6fccf7b8 100644
--- a/src/pkg/encoding/asn1/asn1_test.go
+++ b/src/pkg/encoding/asn1/asn1_test.go
@@ -223,13 +223,21 @@ var utcTestData = []timeTest{
func TestUTCTime(t *testing.T) {
for i, test := range utcTestData {
ret, err := parseUTCTime([]byte(test.in))
- if (err == nil) != test.ok {
- t.Errorf("#%d: Incorrect error result (did fail? %v, expected: %v)", i, err == nil, test.ok)
- }
- if err == nil {
- if !reflect.DeepEqual(test.out, ret) {
- t.Errorf("#%d: Bad result: %v (expected %v)", i, ret, test.out)
+ if err != nil {
+ if test.ok {
+ t.Errorf("#%d: parseUTCTime(%q) = error %v", i, err)
}
+ 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)
}
}
}