diff options
Diffstat (limited to 'BJC-Utils2/src/test')
| -rw-r--r-- | BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java | 87 |
1 files changed, 80 insertions, 7 deletions
diff --git a/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java b/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java index 371a50a..0230943 100644 --- a/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java +++ b/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java @@ -12,14 +12,14 @@ import org.junit.rules.ExpectedException; import static bjc.utils.parserutils.TokenUtils.*; -public class TokenUtilsTest_removeDQuoted { +public class TokenUtilsTest { @Rule - public ExpectedException exp; - - public TokenUtilsTest_removeDQuoted(ExpectedException exp) { - this.exp = exp; - } - + public ExpectedException exp = ExpectedException.none(); + + /* + * Test removeDQuoted + */ + /* * Check handling of mismatched strings with no matching strings. */ @@ -53,6 +53,25 @@ public class TokenUtilsTest_removeDQuoted { } /* + * Check handling of strings with multiple quoted strings in a row. + */ + @Test + public void testRemoveDQuoted_MultipleSerialString() { + List<String> onMultipleSerialMatchString = removeDQuotedStrings("\"hello\"\"there\""); + + assertThat(onMultipleSerialMatchString, hasItems("\"hello\"", "\"there\"")); + } + + /* + * Check handling of strings with multiple interleaved strings. + */ + @Test + public void testRemoveDQuoted_MultipleInterleavedString() { + List<String> onMultipleInterleaveMatchString = removeDQuotedStrings("one\"two\"three\"four\""); + + assertThat(onMultipleInterleaveMatchString, hasItems("one", "\"two\"", "three", "\"four\"")); + } + /* * Check handling of strings without embedded strings. */ @Test @@ -71,4 +90,58 @@ public class TokenUtilsTest_removeDQuoted { assertThat(onEmptyString, hasItems("")); } + + /* + * Test descapeString + */ + /* + * Check handling of empty strings. + */ + @Test + public void testDescapeString_EmptyString() { + String onEmptyString = descapeString(""); + + assertThat(onEmptyString, is("")); + } + + /* + * Check handling of strings without escapes + */ + @Test + public void testDescapeString_NonescapeString() { + String onNonescapeString = descapeString("hello there"); + + assertThat(onNonescapeString, is("hello there")); + } + + /* + * Check handling of strings with single escapes. + */ + @Test + public void testDescapeString_SingleEscapeString() { + String onSingleEscapeString = descapeString("hello\\tthere"); + + assertThat(onSingleEscapeString, is("hello\tthere")); + } + + /* + * Check handling of strings with multiple escapes. + */ + @Test + public void testDescapeString_MultipleEscapeString() { + String onMultipleEscapeString = descapeString("hello\\tthere\\tworld"); + + assertThat(onMultipleEscapeString, is("hello\tthere\tworld")); + } + + /* + * Check handling of strings with invalid single escapes. + */ + @Test + public void testDescapeString_InvalidSingleEscapeString() throws IllegalArgumentException { + exp.expect(IllegalArgumentException.class); + exp.expectMessage(containsString("at position 0")); + + descapeString("\\x"); + } }
\ No newline at end of file |
