-
Notifications
You must be signed in to change notification settings - Fork 12
/
feed_test.go
24 lines (21 loc) · 1.21 KB
/
feed_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
package main
import "testing"
func TestFileNameTruncation(t *testing.T) {
names := []string{
"我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我", // 255 x Chinese wo3 (我)
"我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我", // 256 x Chinese wo3 (我)
"我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我我", // 32 x Chinese wo3 (我)
"short"} // should not get truncated
for _, name := range names {
shortened := truncateString(name, maxFileNameLength)
if len(name) < maxFileNameLength {
if name != shortened {
t.Errorf("Filename should not be altered, but it was. Original was %s", name)
}
} else {
if len(shortened) > maxFileNameLength {
t.Errorf("Filename was too long - should have been truncated. Length was %d", len(name))
}
}
}
}