summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2019-06-24 20:35:41 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2019-06-24 20:35:41 -0400
commiteb703a69c83a0bdb3d2172b0bd26d38188ecbe86 (patch)
tree85b39bbc362e07e01c5e010a4af75084aa78c27a /src/test
parent1ab7c6b0e02cdbc2dd911bb9df8a5bc6467d0434 (diff)
Fix some bugs in escapeSplit
The main bug was that if you started the string with a delimiter, you would only get an empty string as a result. Turns out endsWith("") is usually true :-| Also, added some more tests, and some more early outs to escapeSplit.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/bjc/everge/StringUtilsTest.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/java/bjc/everge/StringUtilsTest.java b/src/test/java/bjc/everge/StringUtilsTest.java
index 9edc028..9eac017 100644
--- a/src/test/java/bjc/everge/StringUtilsTest.java
+++ b/src/test/java/bjc/everge/StringUtilsTest.java
@@ -28,6 +28,13 @@ public class StringUtilsTest {
assertSplitsTo("a / b/c", "/", " ", "a", "/ ", "b/c");
}
+ @Test
+ public void testEdgeSplit() {
+ // Starting with the delimiter doesn't create a blank string
+ assertSplitsTo("/a", "|", "/", "", "a");
+ assertSplitsTo("a/", "|", "/", "a");
+ }
+
private void assertSplitsTo(String inp, String esc, String splat, String... right) {
try {
String[] lst = StringUtils.escapeSplit(esc, splat, inp);