BAEL-4702 Added code snippet for System.lineSeparator() method
This commit is contained in:
parent
bfca572d04
commit
d954c180e5
@ -4,6 +4,12 @@ import org.junit.Test;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class SplitStringByNewLineUnitTest {
|
public class SplitStringByNewLineUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenString_whenSplitByNewLineUsingSystemLineSeparator_thenReturnsArray() {
|
||||||
|
assertThat("Line1\r\nLine2\r\nLine3".split(System.lineSeparator())).containsExactly("Line1", "Line2", "Line3");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenString_whenSplitByNewLineUsingRegularExpressionPattern_thenReturnsArray() {
|
public void givenString_whenSplitByNewLineUsingRegularExpressionPattern_thenReturnsArray() {
|
||||||
assertThat("Line1\nLine2\nLine3".split("\\r?\\n|\\r")).containsExactly("Line1", "Line2", "Line3");
|
assertThat("Line1\nLine2\nLine3".split("\\r?\\n|\\r")).containsExactly("Line1", "Line2", "Line3");
|
||||||
@ -21,4 +27,6 @@ public class SplitStringByNewLineUnitTest {
|
|||||||
|
|
||||||
assertThat("Line1\r\nLine2\r\nLine3".split("\\R")).containsExactly("Line1", "Line2", "Line3");
|
assertThat("Line1\r\nLine2\r\nLine3".split("\\R")).containsExactly("Line1", "Line2", "Line3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user