forked from valyala/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_test.go
More file actions
30 lines (26 loc) · 780 Bytes
/
util_test.go
File metadata and controls
30 lines (26 loc) · 780 Bytes
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
package fastjson
import (
"testing"
)
func TestStartEndString(t *testing.T) {
f := func(s, expectedResult string) {
t.Helper()
result := startEndString(s)
if result != expectedResult {
t.Fatalf("unexpected result for startEndString(%q); got %q; want %q", s, result, expectedResult)
}
}
f("", "")
f("foo", "foo")
getString := func(n int) string {
b := make([]byte, 0, n)
for i := 0; i < n; i++ {
b = append(b, 'a'+byte(i%26))
}
return string(b)
}
s := getString(maxStartEndStringLen)
f(s, s)
f(getString(maxStartEndStringLen+1), "abcdefghijklmnopqrstuvwxyzabcdefghijklmn...pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc")
f(getString(100*maxStartEndStringLen), "abcdefghijklmnopqrstuvwxyzabcdefghijklmn...efghijklmnopqrstuvwxyzabcdefghijklmnopqr")
}