diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-11 20:54:07 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-11 21:31:52 +0000 |
commit | a18b4b3fb9b1b98f6eefa038b723f99fd6d13efd (patch) | |
tree | 9606593eb9551e011dc17fceddfb8a01f349e818 /src/time/time_test.go | |
parent | e0aedfb496f414e1a869d27175b4dfcc6baef407 (diff) | |
download | go-a18b4b3fb9b1b98f6eefa038b723f99fd6d13efd.tar.gz go-a18b4b3fb9b1b98f6eefa038b723f99fd6d13efd.zip |
time: don't panic stringifying the zero Month
Fixes #17720
Change-Id: Ib95c230deef3934db729856c17908f8e5a1e2b7f
Reviewed-on: https://go-review.googlesource.com/33145
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/time/time_test.go')
-rw-r--r-- | src/time/time_test.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/time/time_test.go b/src/time/time_test.go index 0af9da34a2..07afcffc21 100644 --- a/src/time/time_test.go +++ b/src/time/time_test.go @@ -1117,8 +1117,8 @@ var defaultLocTests = []struct { {"Truncate", func(t1, t2 Time) bool { return t1.Truncate(Hour).Equal(t2.Truncate(Hour)) }}, {"Round", func(t1, t2 Time) bool { return t1.Round(Hour).Equal(t2.Round(Hour)) }}, - - {"== Time{}", func(t1, t2 Time) bool { return (t1==Time{}) == (t2==Time{}) }}, + + {"== Time{}", func(t1, t2 Time) bool { return (t1 == Time{}) == (t2 == Time{}) }}, } func TestDefaultLoc(t *testing.T) { @@ -1230,3 +1230,10 @@ func TestMarshalBinaryZeroTime(t *testing.T) { t.Errorf("t0=%#v\nt1=%#v\nwant identical structures", t0, t1) } } + +// Issue 17720: Zero value of time.Month fails to print +func TestZeroMonthString(t *testing.T) { + if got, want := Month(0).String(), "%!Month(0)"; got != want { + t.Errorf("zero month = %q; want %q", got, want) + } +} |