mox/moxio/base64writer_test.go
Mechiel Lukkien 69d2699961
write base64 message parts with 76 data bytes on a line instead of 78
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.
2025-04-03 10:22:15 +02:00

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)
}
}