-
Notifications
You must be signed in to change notification settings - Fork 3
/
sanitize_test.go
33 lines (30 loc) · 1015 Bytes
/
sanitize_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
package mars
import (
"testing"
)
func TestRemovingLineBreaks(t *testing.T) {
for i, exp := range map[string]string{
"This is a test.": "This is a test.",
"This is\n a test.": "This is a test.",
"This is\r a test.": "This is a test.",
"This is\r\n a test.": "This is a test.",
"\n\n\n\n\nThis is\r a test.": " This is a test.",
} {
if res := removeLineBreaks(i); res != exp {
t.Errorf("Unexpected result '%s' when removing line breaks from '%s'.\n", res, i)
}
}
}
func TestRemovingAllWhitespace(t *testing.T) {
for i, exp := range map[string]string{
"This is a test.": "Thisisatest.",
"This is\n a test.": "Thisisatest.",
"This is\r a test.": "Thisisatest.",
"This is\r\n a test.": "Thisisatest.",
"\n\n\n\n\nThis is\r a test.": "Thisisatest.",
} {
if res := removeAllWhitespace(i); res != exp {
t.Errorf("Unexpected result '%s' when removing all whitespace from '%s'.\n", res, i)
}
}
}