@Test public void replace_last() { assertThat(Strings.replaceLast("", "", "")).isEqualTo(""); assertThat(Strings.replaceLast("", ".jar", ".txt")).isEqualTo(""); assertThat(Strings.replaceLast("name.jar", ".jar", ".txt")).isEqualTo("name.txt"); assertThat(Strings.replaceLast("name.jar", ".toto", ".txt")).isEqualTo("name.jar"); }
@Test public void substring_after() { assertThat(Strings.substringAfter("", "")).isEmpty(); assertThat(Strings.substringAfter("name.jar", ".")).isEqualTo("jar"); assertThat(Strings.substringAfter("name.jar", ".jar")).isEmpty(); assertThat(Strings.substringAfter("name.jar", "name.jar")).isEmpty(); assertThat(Strings.substringAfter("name.jar", "unknown")).isEmpty(); }
@Test public void strip_quotes() { assertThat(Strings.stripQuotes(null)).isNull(); assertThat(Strings.stripQuotes("")).isEmpty(); assertThat(Strings.stripQuotes("TEXT")).isEqualTo("TEXT"); assertThat(Strings.stripQuotes("\"\"")).isEmpty(); assertThat(Strings.stripQuotes("\"TEXT\"")).isEqualTo("TEXT"); }
@Test public void substring_before_last() { assertThat(Strings.substringBeforeLast("", "")).isEmpty(); assertThat(Strings.substringBeforeLast("name.jar", ".")).isEqualTo("name"); assertThat(Strings.substringBeforeLast("name.jar", ".jar")).isEqualTo("name"); assertThat(Strings.substringBeforeLast("name.jar", "name.jar")).isEmpty(); assertThat(Strings.substringBeforeLast("name.jar", "unknown")).isEqualTo("name.jar"); }
@Test public void count_char_matches() { assertThat(Strings.countMatches("123456789", '0')).isZero(); assertThat(Strings.countMatches("123456789", '1')).isEqualTo(1); assertThat(Strings.countMatches("111111111", '1')).isEqualTo(9); }