Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public void should_count_occurrences() throws Exception
assertThat(Strings.countOccurrences("bla<>h<>", "<>")).isEqualTo(2);
}

@Test
public void should_return_zero_when_count_occurrences_is_called_with_empty_strings() throws Exception
{
assertThat(Strings.countOccurrences("", "test")).isEqualTo(0);
assertThat(Strings.countOccurrences(null, "test")).isEqualTo(0);
assertThat(Strings.countOccurrences("test", "")).isEqualTo(0);
assertThat(Strings.countOccurrences("test", null)).isEqualTo(0);
assertThat(Strings.countOccurrences(null, null)).isEqualTo(0);
}

@Test
public void split_should_ignore_blank_parts() throws Exception
{
Expand Down Expand Up @@ -128,6 +138,22 @@ public void join_should_join_given_strings_whith_given_separator() throws Except
assertThat(Strings.join(" -> ", "aBc", "2", "DEf")).isEqualTo("aBc -> 2 -> DEf");
}

@Test
public void join_should_append_to_string_builder_with_given_separator_for_collection() throws Exception
{
StringBuilder sb = new StringBuilder("prefix: ");
Strings.join(sb, ",", java.util.Arrays.asList("1", "2", "3"));
assertThat(sb.toString()).isEqualTo("prefix: 1,2,3");
}

@Test
public void join_should_append_to_string_builder_with_given_separator_for_array() throws Exception
{
StringBuilder sb = new StringBuilder("prefix: ");
Strings.join(sb, " -> ", new String[]{"aBc", "2", "DEf"});
assertThat(sb.toString()).isEqualTo("prefix: aBc -> 2 -> DEf");
}

@Test
public void emptyArray_should_return_empty_array()
{
Expand Down
Loading