### Question:
Tokenizer { public int skipComment() { char current = charAt(offset); char next = charAt(offset + 1); if (isSingleLineCommentBegin(current, next)) { return skipSingleLineComment(COMMENT_BEGIN_SYMBOL_LENGTH); } else if ('#' == current) { return skipSingleLineComment(MYSQL_SPECIAL_COMMENT_BEGIN_SYMBOL_LENGTH); } else if (isMultipleLineCommentBegin(current, next)) { return skipMultiLineComment(); } return offset; }  int skipWhitespace(); int skipComment(); int skipHint(); Token scanVariable(); Token scanIdentifier(); Token scanHexDecimal(); Token scanNumber(); Token scanChars(); Token scanSymbol();  }### Answer:
@Test public void assertSkipCommentWithoutComment() { String sql = "SELECT * FROM XXX_TABLE"; Tokenizer tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("_")); assertThat(tokenizer.skipComment(), is(sql.indexOf("_"))); }
@Test public void assertSkipSingleLineComment() { String singleLineCommentWithHyphen = "--x\"y`z\n"; String singleLineCommentWithSlash = " String sql = "SELECT * FROM XXX_TABLE " + singleLineCommentWithHyphen + "WHERE XX" + singleLineCommentWithSlash + "=1 "; Tokenizer hyphenTokenizer = new Tokenizer(sql, dictionary, sql.indexOf("-")); int expected = sql.indexOf("-") + singleLineCommentWithHyphen.length(); assertThat(hyphenTokenizer.skipComment(), is(expected)); Tokenizer slashTokenizer = new Tokenizer(sql, dictionary, sql.indexOf("/")); expected = sql.indexOf("/") + singleLineCommentWithSlash.length(); assertThat(slashTokenizer.skipComment(), is(expected)); }
@Test public void assertSkipSingleLineMySQLComment() { String comment = "#x\"y`z\n"; String sql = "SELECT * FROM XXX_TABLE " + comment + "WHERE XX=1"; Tokenizer tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("#")); int expected = sql.indexOf("#") + comment.length(); assertThat(tokenizer.skipComment(), is(expected)); }
@Test public void assertSkipMultipleLineComment() { String comment = ""; String sql = "SELECT * FROM XXX_TABLE " + comment + "WHERE YY>2"; Tokenizer tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("/")); int expected = sql.indexOf("/") + comment.length(); assertThat(tokenizer.skipComment(), is(expected)); }
@Test(expected = UnterminatedCharException.class) public void assertSkipMultipleLineCommentUnterminatedCharException() { String comment = "/*--xyz \n WHERE XX=1 String sql = "SELECT * FROM XXX_TABLE " + comment; Tokenizer tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("/")); tokenizer.skipComment(); }