Add tests for StringUtils split() method

Closes gh-24351
This commit is contained in:
hyeonisism 2020-01-15 01:20:38 +09:00 committed by Sam Brannen
parent 0f5103de45
commit f1827cb1f9
1 changed files with 16 additions and 0 deletions

View File

@ -745,4 +745,20 @@ class StringUtilsTests {
assertThat(StringUtils.parseLocale("")).isNull();
}
@Test
void split() {
assertThat(StringUtils.split("Hello, world", ",")).isEqualTo(new String[]{"Hello", " world"});
assertThat(StringUtils.split(",Hello world", ",")).isEqualTo(new String[]{"", "Hello world"});
assertThat(StringUtils.split("Hello world,", ",")).isEqualTo(new String[]{"Hello world", ""});
assertThat(StringUtils.split("Hello, world,", ",")).isEqualTo(new String[]{"Hello", " world,"});
}
@Test
void splitWithEmptyString() {
assertThat(StringUtils.split("Hello, world", "")).isNull();
assertThat(StringUtils.split("", ",")).isNull();
assertThat(StringUtils.split(null, ",")).isNull();
assertThat(StringUtils.split("Hello, world", null)).isNull();
assertThat(StringUtils.split(null, null)).isNull();
}
}