strcase/camel_test.go

42 lines
866 B
Go
Raw Normal View History

2015-10-09 17:13:05 +08:00
package strcase
import (
"testing"
)
func TestToCamel(t *testing.T) {
cases := [][]string{
2017-11-29 09:02:53 +08:00
[]string{"test_case", "TestCase"},
[]string{"test", "Test"},
[]string{"TestCase", "TestCase"},
[]string{" test case ", "TestCase"},
[]string{"", ""},
[]string{"many_many_words", "ManyManyWords"},
[]string{"AnyKind of_string", "AnyKindOfString"},
[]string{"odd-fix", "OddFix"},
[]string{"numbers2And55with000", "Numbers2And55With000"},
2015-10-09 17:13:05 +08:00
}
for _, i := range cases {
in := i[0]
out := i[1]
result := ToCamel(in)
if result != out {
t.Error("'" + result + "' != '" + out + "'")
}
}
}
2017-06-15 10:33:52 +08:00
func TestToLowerCamel(t *testing.T) {
cases := [][]string{
2017-11-29 09:02:53 +08:00
[]string{"foo-bar", "fooBar"},
2017-06-15 10:33:52 +08:00
}
for _, i := range cases {
in := i[0]
out := i[1]
result := ToLowerCamel(in)
if result != out {
t.Error("'" + result + "' != '" + out + "'")
}
}
}