package testmysql ; import com.mysql.jdbc.StringUtils ; public class TestComments { public static void main (String [] args) { assertOffset (0, StringUtils.getOffset ("SELECT")) ; assertOffset (1, StringUtils.getOffset ("\nSELECT")) ; assertOffset (7, StringUtils.getOffset (" \t \r \n SELECT")) ; assertOffset (16, StringUtils.getOffset ("# comment here \nSELECT")) ; assertOffset (18, StringUtils.getOffset ("/* comment here */SELECT")) ; assertOffset (19, StringUtils.getOffset ("/* comment her*e */SELECT")) ; assertOffset (20, StringUtils.getOffset ("/* comment her*e/ */SELECT")) ; assertOffset (20, StringUtils.getOffset ("/* comment-- here */SELECT")) ; assertOffset (19, StringUtils.getOffset ("/* comment# here */SELECT")) ; assertOffset (4, StringUtils.getOffset ("-- \nSELECT")) ; assertOffset (0, StringUtils.getOffset ("- - SELECT")) ; assertOffset (0, StringUtils.getOffset ("--SELECT")) ; assertOffset (8, StringUtils.getOffset ("/*SELECT")) ; assertOffset (0, StringUtils.getOffset ("/ *SELECT")) ; assertOffset (0, StringUtils.getOffset ("")) ; assertOffset (0, StringUtils.getOffset (null)) ; } public static void assertOffset (int expected, int actual) { if (expected != actual) { throw new RuntimeException ("Expected " + expected + ", but found " + actual) ; } } }