@Test public void testPrintfNextTermFails() { try { int unused = PrintfMessageParser.nextPrintfTerm("Hello %", 0); fail("expected ParseException"); } catch (ParseException expected) { assertThat(expected.getMessage()).contains("[%]"); } }
static int nextPrintfTerm(String message, int pos) throws ParseException { while (pos < message.length()) { if (message.charAt(pos++) != '%') { continue; } if (pos < message.length()) { char c = message.charAt(pos); if (c == '%' || c == 'n') { pos += 1; continue; } return pos - 1; } throw ParseException.withStartPosition("trailing unquoted '%' character", message, pos - 1); } return -1; }
PrintfMessageParser extends MessageParser { static int nextPrintfTerm(String message, int pos) throws ParseException { while (pos < message.length()) { if (message.charAt(pos++) != '%') { continue; } if (pos < message.length()) { char c = message.charAt(pos); if (c == '%' || c == 'n') { pos += 1; continue; } return pos - 1; } throw ParseException.withStartPosition("trailing unquoted '%' character", message, pos - 1); } return -1; } }
PrintfMessageParser extends MessageParser { static int nextPrintfTerm(String message, int pos) throws ParseException { while (pos < message.length()) { if (message.charAt(pos++) != '%') { continue; } if (pos < message.length()) { char c = message.charAt(pos); if (c == '%' || c == 'n') { pos += 1; continue; } return pos - 1; } throw ParseException.withStartPosition("trailing unquoted '%' character", message, pos - 1); } return -1; }  }
PrintfMessageParser extends MessageParser { static int nextPrintfTerm(String message, int pos) throws ParseException { while (pos < message.length()) { if (message.charAt(pos++) != '%') { continue; } if (pos < message.length()) { char c = message.charAt(pos); if (c == '%' || c == 'n') { pos += 1; continue; } return pos - 1; } throw ParseException.withStartPosition("trailing unquoted '%' character", message, pos - 1); } return -1; }  @Override final void unescape(StringBuilder out, String message, int start, int end); }
PrintfMessageParser extends MessageParser { static int nextPrintfTerm(String message, int pos) throws ParseException { while (pos < message.length()) { if (message.charAt(pos++) != '%') { continue; } if (pos < message.length()) { char c = message.charAt(pos); if (c == '%' || c == 'n') { pos += 1; continue; } return pos - 1; } throw ParseException.withStartPosition("trailing unquoted '%' character", message, pos - 1); } return -1; }  @Override final void unescape(StringBuilder out, String message, int start, int end);  }