added inflector.Camelize helper

This commit is contained in:
Gani Georgiev
2025-01-24 14:49:28 +02:00
parent 65440314ce
commit c101798516
4 changed files with 60 additions and 1 deletions

View File

@@ -143,3 +143,33 @@ func TestSnakecase(t *testing.T) {
})
}
}
func TestCamelize(t *testing.T) {
scenarios := []struct {
val string
expected string
}{
{"", ""},
{" ", ""},
{"Test", "Test"},
{"test", "Test"},
{"testTest2", "TestTest2"},
{"TestTest2", "TestTest2"},
{"test test2", "TestTest2"},
{"test-test2", "TestTest2"},
{"test'test2", "TestTest2"},
{"test1test2", "Test1test2"},
{"1test-test2", "1testTest2"},
{"123", "123"},
{"123a", "123a"},
}
for i, s := range scenarios {
t.Run(fmt.Sprintf("%d_%#v", i, s.val), func(t *testing.T) {
result := inflector.Camelize(s.val)
if result != s.expected {
t.Fatalf("Expected %q, got %q", s.expected, result)
}
})
}
}