File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ import (
6
6
)
7
7
8
8
func LowerTitle (s string ) string {
9
+ if s == "" {
10
+ return s
11
+ }
12
+
9
13
a := []rune (s )
10
14
a [0 ] = unicode .ToLower (a [0 ])
11
15
return string (a )
Original file line number Diff line number Diff line change
1
+ package codegen
2
+
3
+ import (
4
+ "testing"
5
+ )
6
+
7
+ func TestLowerTitle (t * testing.T ) {
8
+
9
+ // empty
10
+ if LowerTitle ("" ) != "" {
11
+ t .Fatal ("expected empty title to remain empty" )
12
+ }
13
+
14
+ // all lowercase
15
+ if LowerTitle ("lowercase" ) != "lowercase" {
16
+ t .Fatal ("expected no changes when input is all lowercase" )
17
+ }
18
+
19
+ // all uppercase
20
+ if LowerTitle ("UPPERCASE" ) != "uPPERCASE" {
21
+ t .Fatal ("expected first rune to be lower when input is all uppercase" )
22
+ }
23
+
24
+ // Title Case
25
+ if LowerTitle ("Title Case" ) != "title Case" {
26
+ t .Fatal ("expected first rune to be lower when input is Title Case" )
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments