forked from redis/go-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_test.go
53 lines (42 loc) · 1 KB
/
util_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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package internal
import (
"strings"
"testing"
. "github.com/bsm/ginkgo/v2"
. "github.com/bsm/gomega"
)
func BenchmarkToLowerStd(b *testing.B) {
str := "AaBbCcDdEeFfGgHhIiJjKk"
for i := 0; i < b.N; i++ {
_ = strings.ToLower(str)
}
}
// util.ToLower is 3x faster than strings.ToLower.
func BenchmarkToLowerInternal(b *testing.B) {
str := "AaBbCcDdEeFfGgHhIiJjKk"
for i := 0; i < b.N; i++ {
_ = ToLower(str)
}
}
func TestToLower(t *testing.T) {
It("toLower", func() {
str := "AaBbCcDdEeFfGg"
Expect(ToLower(str)).To(Equal(strings.ToLower(str)))
str = "ABCDE"
Expect(ToLower(str)).To(Equal(strings.ToLower(str)))
str = "ABCDE"
Expect(ToLower(str)).To(Equal(strings.ToLower(str)))
str = "abced"
Expect(ToLower(str)).To(Equal(strings.ToLower(str)))
})
}
func TestIsLower(t *testing.T) {
It("isLower", func() {
str := "AaBbCcDdEeFfGg"
Expect(isLower(str)).To(BeFalse())
str = "ABCDE"
Expect(isLower(str)).To(BeFalse())
str = "abcdefg"
Expect(isLower(str)).To(BeTrue())
})
}