class StringLooperTester { public static void main( String[] args ) { StringLooper looper = new StringLooper(); System.out.println( "\nTest some okay (but contrived) ISBNs: " ); checkExpect( looper.isValidISBN10("0000000000"), true ); checkExpect( looper.isValidISBN10("1000000001"), true ); checkExpect( looper.isValidISBN10("0100000002"), true ); checkExpect( looper.isValidISBN10("0010000003"), true ); checkExpect( looper.isValidISBN10("0001000004"), true ); checkExpect( looper.isValidISBN10("0000000019"), true ); checkExpect( looper.isValidISBN10("0000000027"), true ); checkExpect( looper.isValidISBN10("2000000010"), true ); checkExpect( looper.isValidISBN10("4000000020"), true ); checkExpect( looper.isValidISBN10("5000000080"), true ); System.out.println( "\nTest some real and incorrect ISBNs: " ); checkExpect( looper.isValidISBN10("0306406152"), true ); checkExpect( looper.isValidISBN10("0306406162"), false ); checkExpect( looper.isValidISBN10("0306406154"), false ); checkExpect( looper.isValidISBN10("0553565699"), true ); checkExpect( looper.isValidISBN10("1553565699"), false ); System.out.println( "\nTest some X-digit ISBNs: " ); checkExpect( looper.isValidISBN10("000000000X"), false ); checkExpect( looper.isValidISBN10("050000000X"), true ); checkExpect( looper.isValidISBN10("000020000X"), true ); checkExpect( looper.isValidISBN10("300000002X"), true ); } static void checkExpect( boolean actual, boolean expected ) { if (actual == expected) { System.out.print("."); } else { System.out.println("failed test: expected " + expected + ", got " + actual ); } } }