1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
package coding_test
import (
"testing"
"github.com/jhillyerd/enmime/internal/coding"
)
func TestFromIDHeader(t *testing.T) {
testCases := []struct {
input, want string
}{
{"", ""},
{"<>", ""},
{"<%🤯>", "%🤯"},
{"<foo@inbucket.org>", "foo@inbucket.org"},
{"<foo%25bar>", "foo%bar"},
{"foo+bar", "foo bar"},
}
for _, tc := range testCases {
t.Run(tc.input, func(t *testing.T) {
got := coding.FromIDHeader(tc.input)
if got != tc.want {
t.Errorf("got %q, want %q", got, tc.want)
}
})
}
}
func TestToIDHeader(t *testing.T) {
testCases := []struct {
input, want string
}{
{"", "<>"},
{"foo@inbucket.org", "<foo@inbucket.org>"},
{"foo%bar", "<foo%25bar>"},
{"foo bar", "<foo+bar>"},
}
for _, tc := range testCases {
t.Run(tc.input, func(t *testing.T) {
got := coding.ToIDHeader(tc.input)
if got != tc.want {
t.Errorf("got %q, want %q", got, tc.want)
}
})
}
}
|