Ejemplo n.º 1
0
 @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");
 }
Ejemplo n.º 2
0
 @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();
 }
Ejemplo n.º 3
0
 @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");
 }
Ejemplo n.º 4
0
 @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");
 }
Ejemplo n.º 5
0
 @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);
 }