diff --git a/encoding.go b/encoding.go index dff1e6f..0aed3d3 100644 --- a/encoding.go +++ b/encoding.go @@ -152,12 +152,17 @@ const ( MIMERelated MIMEType = "related" ) -// String is a standard method to convert an Encoding into a printable format -func (e Encoding) String() string { - return string(e) -} - // String is a standard method to convert an Charset into a printable format func (c Charset) String() string { return string(c) } + +// String is a standard method to convert an ContentType into a printable format +func (c ContentType) String() string { + return string(c) +} + +// String is a standard method to convert an Encoding into a printable format +func (e Encoding) String() string { + return string(e) +} diff --git a/encoding_test.go b/encoding_test.go index 71624f3..4a3affc 100644 --- a/encoding_test.go +++ b/encoding_test.go @@ -27,6 +27,38 @@ func TestEncoding_String(t *testing.T) { } } +// TestContentType_String tests the string method of the ContentType object +func TestContentType_String(t *testing.T) { + tests := []struct { + name string + ct ContentType + want string + }{ + {"ContentType: text/plain", TypeTextPlain, "text/plain"}, + {"ContentType: text/html", TypeTextHTML, "text/html"}, + { + "ContentType: application/octet-stream", TypeAppOctetStream, + "application/octet-stream", + }, + { + "ContentType: application/pgp-signature", TypePGPSignature, + "application/pgp-signature", + }, + { + "ContentType: application/pgp-encrypted", TypePGPEncrypted, + "application/pgp-encrypted", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.ct.String() != tt.want { + t.Errorf("wrong string for Content-Type returned. Expected: %s, got: %s", + tt.want, tt.ct.String()) + } + }) + } +} + // TestCharset_String tests the string method of the Charset object func TestCharset_String(t *testing.T) { tests := []struct { diff --git a/header.go b/header.go index 4fca337..35c5284 100644 --- a/header.go +++ b/header.go @@ -73,6 +73,9 @@ const ( // HeaderPriority represents the "Priority" field HeaderPriority Header = "Priority" + // HeaderReferences is the "References" header field + HeaderReferences Header = "References" + // HeaderReplyTo is the "Reply-To" header field HeaderReplyTo Header = "Reply-To" diff --git a/header_test.go b/header_test.go index aea2f4c..a060ae6 100644 --- a/header_test.go +++ b/header_test.go @@ -87,6 +87,7 @@ func TestHeader_String(t *testing.T) { {"Header: Organization", HeaderOrganization, "Organization"}, {"Header: Precedence", HeaderPrecedence, "Precedence"}, {"Header: Priority", HeaderPriority, "Priority"}, + {"Header: HeaderReferences", HeaderReferences, "References"}, {"Header: Reply-To", HeaderReplyTo, "Reply-To"}, {"Header: Subject", HeaderSubject, "Subject"}, {"Header: User-Agent", HeaderUserAgent, "User-Agent"},