Created
October 9, 2014 07:15
-
-
Save arialdomartini/b0af26127c06522c3b16 to your computer and use it in GitHub Desktop.
How Java splits strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.jobrapido.fo.api.v1.resources; | |
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.assertNotNull; | |
public class SplitTest { | |
@Test | |
public void aStringSplittedWithItselfIsNotNull() { | |
final String[] actual = "</span>".split("</span>"); | |
assertNotNull(actual); | |
} | |
@Test | |
public void aStringSplittedWithItselfReturnsAListWithNoElements() { | |
final String[] actual = "</span>".split("</span>"); | |
assertEquals(0, actual.length); | |
} | |
@Test | |
public void aCharacterBeforeExtractTheCharacterItself() { | |
final String[] actual = "xxx</span>".split("</span>"); | |
assertEquals("xxx", actual[0]); | |
} | |
@Test | |
public void aStringAfterExtractNothing() { | |
final String[] actual = "</span>yyy".split("</span>"); | |
assertEquals("", actual[0]); | |
} | |
@Test | |
public void bothStringsBeforeAndAfterExtractNothing() { | |
final String[] actual = "xxx</span>yyy".split("</span>"); | |
assertEquals("xxx", actual[0]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment