mirror of
https://github.com/mjl-/mox.git
synced 2025-06-27 21:48:16 +03:00

As required by RFC 2045 (MIME). The 78 byte lines work in practice, except that SpamAssassin has rules that give messages with 78-byte lines spam points. Mentioned by kjetilho on irc.
21 lines
517 B
Go
21 lines
517 B
Go
package moxio
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBase64Writer(t *testing.T) {
|
|
var sb strings.Builder
|
|
bw := Base64Writer(&sb)
|
|
_, err := bw.Write([]byte("0123456789012345678901234567890123456789012345678901234567890123456789"))
|
|
tcheckf(t, err, "write")
|
|
err = bw.Close()
|
|
tcheckf(t, err, "close")
|
|
s := sb.String()
|
|
exp := "MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2\r\nNzg5MDEyMzQ1Njc4OQ==\r\n"
|
|
if s != exp {
|
|
t.Fatalf("base64writer, got %q, expected %q", s, exp)
|
|
}
|
|
}
|