parent
f1827cb1f9
commit
6c2cb8ecf5
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -747,18 +747,19 @@ class StringUtilsTests {
|
|||
|
||||
@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,"});
|
||||
assertThat(StringUtils.split("Hello, world", ",")).containsExactly("Hello", " world");
|
||||
assertThat(StringUtils.split(",Hello world", ",")).containsExactly("", "Hello world");
|
||||
assertThat(StringUtils.split("Hello world,", ",")).containsExactly("Hello world", "");
|
||||
assertThat(StringUtils.split("Hello, world,", ",")).containsExactly("Hello", " world,");
|
||||
}
|
||||
|
||||
@Test
|
||||
void splitWithEmptyString() {
|
||||
void splitWithEmptyStringOrNull() {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue