-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstrStr_test.go
More file actions
34 lines (30 loc) · 746 Bytes
/
Copy pathstrStr_test.go
File metadata and controls
34 lines (30 loc) · 746 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
31
32
33
34
package implementstrstr
import (
"testing"
"github.com/WindomZ/testify/assert"
)
func Test_strStr(t *testing.T) {
assert.Equal(t, 0, strStr("", ""))
assert.Equal(t, 0, strStr("A", ""))
assert.Equal(t, 1, strStr("ABC", "B"))
assert.Equal(t, 2, strStr("ABCDE", "CD"))
assert.Equal(t, 3, strStr("ABCDEFG", "DEF"))
assert.Equal(t, 8, strStr("ABCDEFGHI", "I"))
assert.Equal(t, -1, strStr("ABCDEFGHIJK", "HIK"))
}
func Benchmark_strStr(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.StartTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
strStr("", "")
strStr("A", "")
strStr("ABC", "B")
strStr("ABCDE", "CD")
strStr("ABCDEFG", "DEF")
strStr("ABCDEFGHI", "I")
strStr("ABCDEFGHIJK", "HIK")
}
})
}