@Override public final char[] findNextChar( int match, int esc ) { return findNextChar(false, false, match, esc); }
@Override public final char[] findNextChar( int match, int esc ) { return findNextChar(false, false, match, esc); }
@Override public final char[] findNextChar( int match, int esc ) { return findNextChar(false, false, match, esc); }
@Test public void testEscapeOnBorder() { String hellString = "'1\\'a\\'b\\'c\\'\\'' '123' ".replace('\'', '\"'); initSourceWithString(hellString, 10); puts(hellString); String output; output = new String(source.findNextChar('\"', '\\')); puts("output", '\n', output, '\n', "1\\\"a\\\"b\\\"c\\\"\\\""); Str.equalsOrDie(output, "1\\\"a\\\"b\\\"c\\\"\\\""); initSourceWithString(hellString, 3); output = new String(source.findNextChar('\"', '\\')); puts("output", '\n', output, '\n', "1\\\"a\\\"b\\\"c\\\"\\\""); Str.equalsOrDie(output, "1\\\"a\\\"b\\\"c\\\"\\\""); }
char results2[] = findNextChar(true, wasEscapeChar, match, esc); return Chr.add(results, results2); } else {
char results2[] = findNextChar(true, wasEscapeChar, match, esc); return Chr.add(results, results2); } else {
char results2[] = findNextChar(true, wasEscapeChar, match, esc); return Chr.add(results, results2); } else {
@Test public void stringBug2() { String testString = "\"\""; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "".toCharArray ()) || die(new String(chars)); }
@Test public void stringBug() { String testString = " \"file\""; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "file".toCharArray ()) || die(new String(chars)); }
@Test public void findString2() { String testString = "\"train\""; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train".toCharArray ()) || die(new String(chars)); }
@Test public void findString3() { String testString = "12345 \"train brain stain fain\" 678910"; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train brain stain fain".toCharArray ()) || die(new String(chars)); }
@Test public void findStringWithFindNextCharWithEscape() { String testString = "abc \"train a\\b\" abc"; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train a\\b".toCharArray ()) || die(new String(chars)); ok |= source.currentChar () == ' ' || die("" + (char)source.currentChar()); }
@Test public void findStringWithFindNextChar() { String testString = "abc \"train\" abc"; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); outputs( "current char", ( char ) i ); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; outputs( new String( chars ) ); ok &= Chr.equals( chars, "train".toCharArray ()) || die(new String(chars)); ok |= source.currentChar () == ' ' || die("" + (char)source.currentChar()); }
@Test public void findStringWithFindNextCharWithEscapeOfQuote() { String testString = "abc \"train\\\"\" abc0123456789"; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train\\\"".toCharArray ()) || die(new String(chars)); ok |= source.currentChar () == ' ' || die("" + (char)source.currentChar()); }
@Test public void findStringWithFindNextCharWithEscape2() { String testString = "0123\"dog bog\" z"; initSourceWithString(testString); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case '"': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); source.nextChar(); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "dog bog".toCharArray ()) || die(new String(chars)); ok |= source.currentChar () == ' ' || die("" + (char)source.currentChar()); } @Test public void findStringWithFindNextCharWithEscapeOfQuote() {