Fix ToLowerCamel with leading space

Closes #25
This commit is contained in:
Ian Coleman 2020-08-26 08:46:32 +10:00
parent 23e9d4e5c0
commit 692d1b89fe
3 changed files with 5 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import (
// Converts a string to CamelCase
func toCamelInitCase(s string, initCase bool) string {
s = strings.TrimSpace(s)
if s == "" {
return s
}

View File

@ -68,6 +68,8 @@ func toLowerCamel(tb testing.TB) {
{"AnyKind of_string", "anyKindOfString"},
{"AnyKind.of-string", "anyKindOfString"},
{"ID", "id"},
{"some string", "someString"},
{" some string", "someString"},
}
for _, i := range cases {
in := i[0]

View File

@ -54,6 +54,8 @@ func toSnake(tb testing.TB) {
{"A1 A2 A3", "a_1_a_2_a_3"},
{"AB1AB2AB3", "ab_1_ab_2_ab_3"},
{"AB1 AB2 AB3", "ab_1_ab_2_ab_3"},
{"some string", "some_string"},
{" some string", "some_string"},
}
for _, i := range cases {
in := i[0]