mirror of https://github.com/gobeam/stringy.git
Merge pull request #21 from gobeam/fix/camelCase
fix: camelcase result as pascal case issue resolved
This commit is contained in:
commit
2605d35cf6
|
@ -119,8 +119,12 @@ func (i *input) CamelCase(rule ...string) string {
|
|||
// removing excess space
|
||||
wordArray := caseHelper(input, true, rule...)
|
||||
for i, word := range wordArray {
|
||||
if i == 0 {
|
||||
wordArray[i] = strings.ToLower(word)
|
||||
} else {
|
||||
wordArray[i] = ucfirst(word)
|
||||
}
|
||||
}
|
||||
return strings.Join(wordArray, "")
|
||||
}
|
||||
|
||||
|
|
|
@ -78,16 +78,16 @@ func TestInput_BooleanError(t *testing.T) {
|
|||
func TestInput_CamelCase(t *testing.T) {
|
||||
str := New("Camel case this_complicated__string%%")
|
||||
val := str.CamelCase("%", "")
|
||||
if val != "CamelCaseThisComplicatedString" {
|
||||
t.Errorf("Expected: to be %s but got: %s", "CamelCaseThisComplicatedString", val)
|
||||
if val != "camelCaseThisComplicatedString" {
|
||||
t.Errorf("Expected: to be %s but got: %s", "camelCaseThisComplicatedString", val)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInput_CamelCaseNoRule(t *testing.T) {
|
||||
str := New("Camel case this_complicated__string%%")
|
||||
val := str.CamelCase()
|
||||
if val != "CamelCaseThisComplicatedString%%" {
|
||||
t.Errorf("Expected: to be %s but got: %s", "CamelCaseThisComplicatedString", val)
|
||||
if val != "camelCaseThisComplicatedString%%" {
|
||||
t.Errorf("Expected: to be %s but got: %s", "camelCaseThisComplicatedString", val)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ func TestInput_CamelCaseOddRuleError(t *testing.T) {
|
|||
str := New("Camel case this_complicated__string%%")
|
||||
val := str.CamelCase("%")
|
||||
|
||||
if val != "CamelCaseThisComplicatedString%%" {
|
||||
t.Errorf("Expected: to be %s but got: %s", "CamelCaseThisComplicatedString", val)
|
||||
if val != "camelCaseThisComplicatedString%%" {
|
||||
t.Errorf("Expected: to be %s but got: %s", "camelCaseThisComplicatedString", val)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue