Skip to content

Commit

Permalink
refs #1: fix an edge case and increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
huandu committed Apr 11, 2020
1 parent f0886df commit 2d07d63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func camelCaseToLowerCase(str string, connector rune) string {
}

if len(remaining) == 0 {
toLower(buf, numberWord, word, connector)
break
}

Expand Down
3 changes: 3 additions & 0 deletions convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ func TestToSnakeCaseAndToKebabCase(t *testing.T) {
"Bld4Floor3rd": "bld4_floor_3rd",
" _-_ ": "_____",
"a1b2c3d": "a_1b2c3d",
"A//B%%2c": "a//b%%2c",

"HTTP状态码404/502Error": "http_状态码404/502_error",
"中文(字符)": "中文(字符)",
"混合ABCWords与123数字456": "混合_abc_words_与123_数字456",

" sentence case ": "__sentence_case__",
" Mixed-hyphen case _and SENTENCE_case and UPPER-case": "_mixed_hyphen_case__and_sentence_case_and_upper_case",
"FROM CamelCase to snake/kebab-case": "from_camel_case_to_snake/kebab_case",

"": "",
"Abc\uFFFDE\uFFFDf\uFFFDd\uFFFD2\uFFFD00z\uFFFDZZ\uFFFDZZ": "abc_\uFFFDe\uFFFDf\uFFFDd_\uFFFD2\uFFFD00z_\uFFFDzz\uFFFDzz",
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD": "\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD",
}

runTestCases(t, ToSnakeCase, cases)
Expand Down

0 comments on commit 2d07d63

Please sign in to comment.