@Test public void findStringWithFindNextCharWithEscapeOfQuote() { String testString = "abc \"train \\\"\" abc0123456789"; source = new CharArrayCharacterSource ( testString ); boolean found = false; loop: while (source.hasChar()) { int i = source.nextChar (); switch ( i ) { case '"': found = true; break loop; } } boolean ok = found || die("not found"); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train \\\"".toCharArray ()) || die(new String(chars)); ok |= source.currentChar() == ' ' || die("" + (char)source.currentChar()); ok |= source.location() == 14 || die("" + source.location()); }
@Test public void findStringWithFindNextChar() { String testString = "abc \"train\" abc"; source = new CharArrayCharacterSource ( testString ); boolean found = false; loop: while (source.hasChar()) { int i = source.nextChar (); switch ( i ) { case '"': found = true; break loop; } } boolean ok = found || die("not found"); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train".toCharArray ()) || die(new String(chars)); ok |= source.currentChar() == ' ' || die("" + (char)source.currentChar()); ok |= source.location() == 11 || die("" + source.location()); }
@Test public void findStringWithFindNextCharWithEscape() { String testString = "abc \"train \\b\" abc"; source = new CharArrayCharacterSource ( testString ); boolean found = false; loop: while (source.hasChar()) { int i = source.nextChar (); switch ( i ) { case '"': found = true; break loop; } } boolean ok = found || die("not found"); char [] chars = source.findNextChar ( '"', '\\' ) ; ok &= Chr.equals( chars, "train \\b".toCharArray ()) || die(new String(chars)); ok |= source.currentChar() == ' ' || die("" + (char)source.currentChar()); ok |= source.location() == 14 || die("" + source.location()); }