Skip to content

Commit 33dcf91

Browse files
committed
TestCapitalize
1 parent 5e9ce17 commit 33dcf91

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

stringutil/string_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ import (
2222
"testing"
2323
)
2424

25+
func TestCapitalize(t *testing.T) {
26+
if ret := Capitalize(""); ret != "" {
27+
t.Fatal("Capitalize:", ret)
28+
}
29+
if ret := Capitalize("hello"); ret != "Hello" {
30+
t.Fatal("Capitalize:", ret)
31+
}
32+
if ret := Capitalize("Hello"); ret != "Hello" {
33+
t.Fatal("Capitalize:", ret)
34+
}
35+
}
36+
2537
func TestConcat(t *testing.T) {
2638
if ret := Concat("1"); ret != "1" {
2739
t.Fatal("Concat(1):", ret)

stringutil/transform.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
// its upper case.
2626
func Capitalize(str string) string {
2727
c, nc := utf8.DecodeRuneInString(str)
28-
if c == utf8.RuneError || unicode.IsUpper(c) {
28+
if unicode.IsUpper(c) || c == utf8.RuneError {
2929
return str
3030
}
3131
ret := make([]byte, len(str))

0 commit comments

Comments
 (0)