go-mail/encoding_test.go
Winni Neessen 31001e87b2
#24: Add SPDX license IDs for REUSE compliance
# SUMMARY

* Bad licenses:
* Deprecated licenses:
* Licenses without file extension:
* Missing licenses:
* Unused licenses:
* Used licenses: CC0-1.0, MIT
* Read errors: 0
* Files with copyright information: 45 / 45
* Files with license information: 45 / 45

Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
2022-06-17 15:05:54 +02:00

78 lines
2.8 KiB
Go

// SPDX-FileCopyrightText: 2022 Winni Neessen <winni@neessen.dev>
//
// SPDX-License-Identifier: MIT
package mail
import "testing"
// TestEncoding_String tests the string method of the Encoding object
func TestEncoding_String(t *testing.T) {
tests := []struct {
name string
e Encoding
want string
}{
{"Encoding: Base64", EncodingB64, "base64"},
{"Encoding: QP", EncodingQP, "quoted-printable"},
{"Encoding: None/8bit", NoEncoding, "8bit"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.e.String() != tt.want {
t.Errorf("wrong string for Encoding returned. Expected: %s, got: %s",
tt.want, tt.e.String())
}
})
}
}
// TestCharset_String tests the string method of the Charset object
func TestCharset_String(t *testing.T) {
tests := []struct {
name string
c Charset
want string
}{
{"Charset: US-ASCII", CharsetASCII, "US-ASCII"},
{"Charset: UTF-7", CharsetUTF7, "UTF-7"},
{"Charset: UTF-8", CharsetUTF8, "UTF-8"},
{"Charset: ISO-8859-1", CharsetISO88591, "ISO-8859-1"},
{"Charset: ISO-8859-2", CharsetISO88592, "ISO-8859-2"},
{"Charset: ISO-8859-3", CharsetISO88593, "ISO-8859-3"},
{"Charset: ISO-8859-4", CharsetISO88594, "ISO-8859-4"},
{"Charset: ISO-8859-5", CharsetISO88595, "ISO-8859-5"},
{"Charset: ISO-8859-6", CharsetISO88596, "ISO-8859-6"},
{"Charset: ISO-8859-7", CharsetISO88597, "ISO-8859-7"},
{"Charset: ISO-8859-9", CharsetISO88599, "ISO-8859-9"},
{"Charset: ISO-8859-13", CharsetISO885913, "ISO-8859-13"},
{"Charset: ISO-8859-14", CharsetISO885914, "ISO-8859-14"},
{"Charset: ISO-8859-15", CharsetISO885915, "ISO-8859-15"},
{"Charset: ISO-8859-16", CharsetISO885916, "ISO-8859-16"},
{"Charset: ISO-2022-JP", CharsetISO2022JP, "ISO-2022-JP"},
{"Charset: ISO-2022-KR", CharsetISO2022KR, "ISO-2022-KR"},
{"Charset: windows-1250", CharsetWindows1250, "windows-1250"},
{"Charset: windows-1251", CharsetWindows1251, "windows-1251"},
{"Charset: windows-1252", CharsetWindows1252, "windows-1252"},
{"Charset: windows-1255", CharsetWindows1255, "windows-1255"},
{"Charset: windows-1256", CharsetWindows1256, "windows-1256"},
{"Charset: KOI8-R", CharsetKOI8R, "KOI8-R"},
{"Charset: KOI8-U", CharsetKOI8U, "KOI8-U"},
{"Charset: Big5", CharsetBig5, "Big5"},
{"Charset: GB18030", CharsetGB18030, "GB18030"},
{"Charset: GB2312", CharsetGB2312, "GB2312"},
{"Charset: GBK", CharsetGBK, "GBK"},
{"Charset: TIS-620", CharsetTIS620, "TIS-620"},
{"Charset: EUC-KR", CharsetEUCKR, "EUC-KR"},
{"Charset: Shift_JIS", CharsetShiftJIS, "Shift_JIS"},
{"Charset: Unknown", CharsetUnknown, "Unknown"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.c.String() != tt.want {
t.Errorf("wrong string for Charset returned. Expected: %s, got: %s",
tt.want, tt.c.String())
}
})
}
}