diff --git a/camel.go b/camel.go index bd20891..d5e2e2d 100644 --- a/camel.go +++ b/camel.go @@ -24,7 +24,7 @@ func toCamelInitCase(s string, initCase bool) string { n += string(v) } } - if v == '_' || v == ' ' || v == '-' { + if v == '_' || v == ' ' || v == '-' { capNext = true } else { capNext = false @@ -34,9 +34,9 @@ func toCamelInitCase(s string, initCase bool) string { } func ToCamel(s string) string { - return toCamelInitCase(s, true); + return toCamelInitCase(s, true) } func ToLowerCamel(s string) string { - return toCamelInitCase(s, false); + return toCamelInitCase(s, false) } diff --git a/camel_test.go b/camel_test.go index a5242a6..6ef522a 100644 --- a/camel_test.go +++ b/camel_test.go @@ -6,15 +6,15 @@ import ( func TestToCamel(t *testing.T) { cases := [][]string{ - []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" }, + []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"}, } for _, i := range cases { in := i[0] @@ -28,7 +28,7 @@ func TestToCamel(t *testing.T) { func TestToLowerCamel(t *testing.T) { cases := [][]string{ - []string{ "foo-bar", "fooBar" }, + []string{"foo-bar", "fooBar"}, } for _, i := range cases { in := i[0] diff --git a/snake_test.go b/snake_test.go index e30d85c..a0cb26d 100644 --- a/snake_test.go +++ b/snake_test.go @@ -6,20 +6,20 @@ import ( func TestToSnake(t *testing.T) { cases := [][]string{ - []string{ "testCase", "test_case" }, - []string{ "TestCase", "test_case" }, - []string{ "Test Case", "test_case" }, - []string{ " Test Case", "test_case" }, - []string{ "Test Case ", "test_case" }, - []string{ " Test Case ", "test_case" }, - []string{ "test", "test" }, - []string{ "test_case", "test_case" }, - []string{ "Test", "test" }, - []string{ "", "" }, - []string{ "ManyManyWords", "many_many_words" }, - []string{ "manyManyWords", "many_many_words" }, - []string{ "AnyKind of_string", "any_kind_of_string" }, - []string{ "numbers2and55with000", "numbers_2_and_55_with_000" }, + []string{"testCase", "test_case"}, + []string{"TestCase", "test_case"}, + []string{"Test Case", "test_case"}, + []string{" Test Case", "test_case"}, + []string{"Test Case ", "test_case"}, + []string{" Test Case ", "test_case"}, + []string{"test", "test"}, + []string{"test_case", "test_case"}, + []string{"Test", "test"}, + []string{"", ""}, + []string{"ManyManyWords", "many_many_words"}, + []string{"manyManyWords", "many_many_words"}, + []string{"AnyKind of_string", "any_kind_of_string"}, + []string{"numbers2and55with000", "numbers_2_and_55_with_000"}, } for _, i := range cases { in := i[0]