forked from MJKWoolnough/ics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfolder_test.go
40 lines (38 loc) · 1.54 KB
/
folder_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package ics
import (
"bytes"
"io"
"strings"
"testing"
"unicode/utf8"
)
func TestFolder(t *testing.T) {
tests := []struct {
Input, Output string
}{
{"A", "A"},
{"AB", "AB"},
{"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW\r\n XYZ"},
{"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW\r\n XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRS\r\n TUVWXYZ"},
{"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nABCDEFGHIJKLMNOPQRSTUVWXYZ"},
{"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV€XYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV\r\n €XYZ"},
}
var buf bytes.Buffer
for n, test := range tests {
io.Copy(&folder{w: &buf}, strings.NewReader(test.Input))
if str := buf.String(); str != test.Output {
t.Errorf("test %d.1: expecting output %q, got %q", n+1, test.Output, str)
}
buf.Reset()
f := &folder{w: &buf}
var b [4]byte
for _, r := range test.Input {
s := utf8.EncodeRune(b[:], r)
f.Write(b[:s])
}
if str := buf.String(); str != test.Output {
t.Errorf("test %d.2: expecting output %q, got %q", n+1, test.Output, str)
}
buf.Reset()
}
}