diff --git a/src/net/textproto/header_test.go b/src/net/textproto/header_test.go index de9405ca868..255e79a1301 100644 --- a/src/net/textproto/header_test.go +++ b/src/net/textproto/header_test.go @@ -4,7 +4,9 @@ package textproto -import "testing" +import ( + "testing" +) type canonicalHeaderKeyTest struct { in, out string @@ -33,6 +35,17 @@ var canonicalHeaderKeyTests = []canonicalHeaderKeyTest{ {"foo bar", "foo bar"}, } +func TestNilMapSetOrAdd(t *testing.T) { + defer func() { + if r := recover(); r != nil { + t.Errorf("nil MIMEHeader caused panic: %v", r) + } + }() + var h MIMEHeader + h.Set("foo", "bar") + h.Add("biz", "boo") +} + func TestCanonicalMIMEHeaderKey(t *testing.T) { for _, tt := range canonicalHeaderKeyTests { if s := CanonicalMIMEHeaderKey(tt.in); s != tt.out {