### Question:
TokenQueue { public String chompBalanced(char open, char close) { StringBuilder accum = new StringBuilder(); int depth = 0; char last = 0; do { if (isEmpty()) break; Character c = consume(); if (last == 0 || last != ESC) { if (c.equals(open)) depth++; else if (c.equals(close)) depth--; } if (depth > 0 && last != 0) accum.append(c); last = c; } while (depth > 0); return accum.toString(); } TokenQueue(String data); boolean isEmpty(); char peek(); void addFirst(Character c); void addFirst(String seq); boolean matches(String seq); boolean matchesCS(String seq); boolean matchesAny(String... seq); boolean matchesAny(char... seq); boolean matchesStartTag(); boolean matchChomp(String seq); boolean matchesWhitespace(); boolean matchesWord(); void advance(); char consume(); void consume(String seq); String consumeTo(String seq); String consumeToIgnoreCase(String seq); String consumeToAny(String... seq); String chompTo(String seq); String chompToIgnoreCase(String seq); String chompBalanced(char open, char close); static String unescape(String in); boolean consumeWhitespace(); String consumeWord(); String consumeTagName(); String consumeElementSelector(); String consumeCssIdentifier(); String consumeAttributeKey(); String remainder(); String toString();  }### Answer:
@Test public void chompBalanced() { TokenQueue tq = new TokenQueue(":contains(one (two) three) four"); String pre = tq.consumeTo("("); String guts = tq.chompBalanced('(', ')'); String remainder = tq.remainder(); assertEquals(":contains", pre); assertEquals("one (two) three", guts); assertEquals(" four", remainder); }