1package moxio
2
3import (
4 "strings"
5 "testing"
6)
7
8func TestBase64Writer(t *testing.T) {
9 var sb strings.Builder
10 bw := Base64Writer(&sb)
11 _, err := bw.Write([]byte("0123456789012345678901234567890123456789012345678901234567890123456789"))
12 tcheckf(t, err, "write")
13 err = bw.Close()
14 tcheckf(t, err, "close")
15 s := sb.String()
16 exp := "MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nz\r\ng5MDEyMzQ1Njc4OQ==\r\n"
17 if s != exp {
18 t.Fatalf("base64writer, got %q, expected %q", s, exp)
19 }
20}
21