File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ package internal
2+
3+ import (
4+ "strings"
5+ "testing"
6+
7+ . "github.com/bsm/ginkgo/v2"
8+ . "github.com/bsm/gomega"
9+ )
10+
11+ func BenchmarkToLowerStd (b * testing.B ) {
12+ str := "AaBbCcDdEeFfGgHhIiJjKk"
13+ for i := 0 ; i < b .N ; i ++ {
14+ _ = strings .ToLower (str )
15+ }
16+ }
17+
18+ // util.ToLower is 3x faster than strings.ToLower.
19+ func BenchmarkToLowerInternal (b * testing.B ) {
20+ str := "AaBbCcDdEeFfGgHhIiJjKk"
21+ for i := 0 ; i < b .N ; i ++ {
22+ _ = ToLower (str )
23+ }
24+ }
25+
26+ func TestToLower (t * testing.T ) {
27+ It ("toLower" , func () {
28+ str := "AaBbCcDdEeFfGg"
29+ Expect (ToLower (str )).To (Equal (strings .ToLower (str )))
30+
31+ str = "ABCDE"
32+ Expect (ToLower (str )).To (Equal (strings .ToLower (str )))
33+
34+ str = "ABCDE"
35+ Expect (ToLower (str )).To (Equal (strings .ToLower (str )))
36+
37+ str = "abced"
38+ Expect (ToLower (str )).To (Equal (strings .ToLower (str )))
39+ })
40+ }
41+
42+ func TestIsLower (t * testing.T ) {
43+ It ("isLower" , func () {
44+ str := "AaBbCcDdEeFfGg"
45+ Expect (isLower (str )).To (BeFalse ())
46+
47+ str = "ABCDE"
48+ Expect (isLower (str )).To (BeFalse ())
49+
50+ str = "abcdefg"
51+ Expect (isLower (str )).To (BeTrue ())
52+ })
53+ }
You can’t perform that action at this time.
0 commit comments