Debian Codegraph @

internal/coding/idheader_test.go

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