Skip to content

Commit 54abb5f

Browse files
ianlancetaylorbradfitz
authored andcommitted
net/mail: fix new test for systems with different zoneinfo data
Fixes #34854 Change-Id: I7d6819c439e2fdfb19e181b202797fd5851eb002 Reviewed-on: https://go-review.googlesource.com/c/go/+/200839 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 2df5cdb commit 54abb5f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/net/mail/message_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ func TestDateParsingCFWS(t *testing.T) {
168168
// FWS is allowed before zone but HTAB is not handled. Obsolete timezone is handled.
169169
{
170170
"Fri, 21 Nov 1997 09:55:06 CST",
171-
time.Date(1997, 11, 21, 9, 55, 6, 0, time.FixedZone("CST", 0)),
171+
time.Time{},
172172
true,
173173
},
174174
// FWS is allowed after date and a CRLF is already replaced.
175175
{
176176
"Fri, 21 Nov 1997 09:55:06 CST (no leading FWS and a trailing CRLF) \r\n",
177-
time.Date(1997, 11, 21, 9, 55, 6, 0, time.FixedZone("CST", 0)),
177+
time.Time{},
178178
true,
179179
},
180180
// CFWS is a reduced set of US-ASCII where space and accentuated are obsolete. No error.
@@ -229,7 +229,7 @@ func TestDateParsingCFWS(t *testing.T) {
229229
// Invalid month : OCT iso Oct
230230
{
231231
"Fri, 21 OCT 1997 09:55:06 CST",
232-
time.Date(1997, 11, 21, 9, 55, 6, 0, time.FixedZone("", -6*60*60)),
232+
time.Time{},
233233
false,
234234
},
235235
// A too short time zone.
@@ -252,6 +252,9 @@ func TestDateParsingCFWS(t *testing.T) {
252252
date, err := hdr.Date()
253253
if err != nil && test.valid {
254254
t.Errorf("Header(Date: %s).Date(): %v", test.dateStr, err)
255+
} else if err == nil && test.exp.IsZero() {
256+
// OK. Used when exact result depends on the
257+
// system's local zoneinfo.
255258
} else if err == nil && !date.Equal(test.exp) && test.valid {
256259
t.Errorf("Header(Date: %s).Date() = %+v, want %+v", test.dateStr, date, test.exp)
257260
} else if err == nil && !test.valid { // an invalid expression was tested
@@ -261,6 +264,9 @@ func TestDateParsingCFWS(t *testing.T) {
261264
date, err = ParseDate(test.dateStr)
262265
if err != nil && test.valid {
263266
t.Errorf("ParseDate(%s): %v", test.dateStr, err)
267+
} else if err == nil && test.exp.IsZero() {
268+
// OK. Used when exact result depends on the
269+
// system's local zoneinfo.
264270
} else if err == nil && !test.valid { // an invalid expression was tested
265271
t.Errorf("ParseDate(%s) did not return an error but %v", test.dateStr, date)
266272
} else if err == nil && test.valid && !date.Equal(test.exp) {

0 commit comments

Comments
 (0)