MCPcopy Create free account
hub / github.com/buggregator/server / TestDecodeContent

Function TestDecodeContent

modules/smtp/handler_test.go:97–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func 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
131func TestConvertToUTF8(t *testing.T) {
132 t.Run("utf-8 passthrough", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

decodeContentFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected