### Question:
JavaScanner { int tokenEnd(int start) { if (start >= s.length()) { return s.length(); } switch (s.charAt(start)) { case ' ': case '\n': return spaceEnd(start); case '/': if (s.charAt(start + 1) == '*') { return blockCommentEnd(start); } else if (s.charAt(start + 1) == '/') { return lineCommentEnd(start); } else { return start + 1; } case '\'': case '"': case '`': return quoteEnd(start); default: return start + 1; } } JavaScanner(String s);   }### Answer:
@Test public void testScanner() { String input = Joiner.on("").join(TOKENS); ImmutableList.Builder<String> tokensBuilder = ImmutableList.builder(); JavaScanner tokenizer = new JavaScanner(input); int end; for (int i = 0; i < input.length(); i = end) { end = tokenizer.tokenEnd(i); tokensBuilder.add(input.substring(i, end)); } assertThat(tokensBuilder.build()).containsExactlyElementsIn(TOKENS).inOrder(); }