(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func TestDecodeContent(t *testing.T) { |
| 98 | t.Run("base64", func(t *testing.T) { |
| 99 | encoded := "SGVsbG8gV29ybGQ=" // "Hello World" |
| 100 | got := decodeContent([]byte(encoded), "base64") |
| 101 | if string(got) != "Hello World" { |
| 102 | t.Errorf("got %q, want %q", got, "Hello World") |
| 103 | } |
| 104 | }) |
| 105 | |
| 106 | t.Run("quoted-printable", func(t *testing.T) { |
| 107 | encoded := "Hello=20World" |
| 108 | got := decodeContent([]byte(encoded), "quoted-printable") |
| 109 | if string(got) != "Hello World" { |
| 110 | t.Errorf("got %q, want %q", got, "Hello World") |
| 111 | } |
| 112 | }) |
| 113 | |
| 114 | t.Run("no encoding", func(t *testing.T) { |
| 115 | data := []byte("plain text") |
| 116 | got := decodeContent(data, "") |
| 117 | if string(got) != "plain text" { |
| 118 | t.Errorf("got %q", got) |
| 119 | } |
| 120 | }) |
| 121 | |
| 122 | t.Run("7bit passthrough", func(t *testing.T) { |
| 123 | data := []byte("ascii text") |
| 124 | got := decodeContent(data, "7bit") |
| 125 | if string(got) != "ascii text" { |
| 126 | t.Errorf("got %q", got) |
| 127 | } |
| 128 | }) |
| 129 | } |
| 130 | |
| 131 | func TestConvertToUTF8(t *testing.T) { |
| 132 | t.Run("utf-8 passthrough", func(t *testing.T) { |
nothing calls this directly
no test coverage detected