-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathutil_test.go
More file actions
51 lines (47 loc) · 1.07 KB
/
util_test.go
File metadata and controls
51 lines (47 loc) · 1.07 KB
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
41
42
43
44
45
46
47
48
49
50
51
package imap
import (
"testing"
)
func TestDropNl(t *testing.T) {
t.Parallel()
tests := []struct {
name string
input []byte
expected string
}{
{"crlf", []byte("hello\r\n"), "hello"},
{"lf only", []byte("hello\n"), "hello"},
{"no newline", []byte("hello"), "hello"},
{"empty", []byte{}, ""},
{"just lf", []byte("\n"), ""},
{"just crlf", []byte("\r\n"), ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := string(dropNl(tt.input))
if got != tt.expected {
t.Errorf("dropNl(%q) = %q, want %q", tt.input, got, tt.expected)
}
})
}
}
func TestMakeIMAPLiteral(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"test", "{4}\r\ntest"},
{"тест", "{8}\r\nтест"},
{"测试", "{6}\r\n测试"},
{"😀👍", "{8}\r\n😀👍"},
{"Prüfung", "{8}\r\nPrüfung"},
{"", "{0}\r\n"},
}
for _, test := range tests {
got := MakeIMAPLiteral(test.input)
if got != test.expected {
t.Errorf("MakeIMAPLiteral(%q) = %q, want %q", test.input, got, test.expected)
}
}
}