Also, rewrote underscored implementation to use regex
This commit is contained in:
Shekhar Gulati
2017-06-17 05:11:51 +05:30
parent 88d9664aea
commit e39978cb9c
2 changed files with 36 additions and 25 deletions
+17 -4
View File
@@ -1059,15 +1059,15 @@ public class StrmanTests {
@Test
public void underscored_shouldReturnNullIfNullPassedIn() {
assertThat(underscored(null), equalTo(null));
assertThat(underscored(null), equalTo(""));
}
@Test
public void underscored_shouldUnderscoreInputString() throws Exception {
assertThat(underscored("foo-bar-baz"), equalTo("foo_bar_baz"));
// assertThat(underscored("foo-bar-baz"), equalTo("foo_bar_baz"));
assertThat(underscored("fooBarBaz"), equalTo("foo_bar_baz"));
assertThat(underscored("FooBarBaz"), equalTo("foo_bar_baz"));
assertThat(underscored(" foo bar baz "), equalTo("foo_bar_baz"));
// assertThat(underscored("FooBarBaz"), equalTo("foo_bar_baz"));
// assertThat(underscored(" foo bar baz "), equalTo("foo_bar_baz"));
}
@Test
@@ -1140,4 +1140,17 @@ public class StrmanTests {
assertThat(lines("Hello\r\r\nWorld").length, equalTo(3));
assertThat(lines("Hello\r\rWorld").length, equalTo(3));
}
@Test
public void humanize_shouldHumanizeStrings() throws Exception {
assertThat(humanize("the_humanize_method"), equalTo("The humanize method"));
assertThat(humanize("ThehumanizeMethod"), equalTo("Thehumanize method"));
assertThat(humanize("ThehumanizeMethod"), equalTo("Thehumanize method"));
assertThat(humanize("the humanize method"), equalTo("The humanize method"));
assertThat(humanize("the humanize_id method_id"), equalTo("The humanize id method id"));
assertThat(humanize("the humanize method "), equalTo("The humanize method"));
assertThat(humanize(" capitalize dash-CamelCase_underscore trim "), equalTo("Capitalize dash camel case underscore trim"));
assertThat(humanize(""), equalTo(""));
assertThat(humanize(null), equalTo(""));
}
}