class TestVowelExpert { public static void main( String[] args ) { System.out.println( "\n==== Testing ====" ); testFirstA(); testFirstVowel(); testFirstCharFrom(); testPigLatin(); System.out.println( "==== Testing Done ====\n\n" ); } static void testFirstA() { System.out.println(" == firstA =="); testFirstA1( 3, "senator" ); testFirstA1( 1, "yahoo!" ); testFirstA1( 0, "Aardvark" ); testFirstA1( 4, "huh?" ); testFirstA1( 3, "yoga" ); testFirstA1( 3, "yogAaaah" ); testFirstA1( 4, "Ygdrasil" ); testFirstA1( 0, "a" ); testFirstA1( 1, "z" ); testFirstA1( 0, "" ); } static void testFirstA1( int exp, String w ) { VowelExpert ve = new VowelExpert(); testNumeric( exp, ve.firstA(w), "firstA(\""+w+"\")" ); } static void testFirstVowel() { System.out.println(" == firstVowel =="); testFirstVowel1( 1, "senator" ); testFirstVowel1( 1, "yahoo!" ); testFirstVowel1( 0, "Aardvark" ); testFirstVowel1( 1, "huh?" ); testFirstVowel1( 5, "hrgh?" ); testFirstVowel1( 1, "yoga" ); testFirstVowel1( 4, "Ygdrasil" ); testFirstVowel1( 0, "a" ); testFirstVowel1( 1, "z" ); testFirstVowel1( 0, "" ); } static void testFirstVowel1( int exp, String w ) { VowelExpert ve = new VowelExpert(); testNumeric( exp, ve.firstVowel(w), "firstVowel(\""+w+"\")" ); } static void testFirstCharFrom() { System.out.println(" == firstCharFrom =="); testFirstCharFrom1( 2, "senator", "nt" ); testFirstCharFrom1( 0, "senator", "nst" ); testFirstCharFrom1( 7, "senator", "" ); testFirstCharFrom1( 7, "senator", "qzx" ); testFirstCharFrom1( 7, "senator", "SNTR" ); testFirstCharFrom1( 2, "Mississippi", "s" ); testFirstCharFrom1( 5, "yahoo!", "?!" ); testFirstCharFrom1( 0, "a", "Aa" ); testFirstCharFrom1( 1, "a", "Zzzz" ); testFirstCharFrom1( 0, "", "" ); testFirstCharFrom1( 0, "", "Blah blah blah" ); } static void testFirstCharFrom1( int exp, String w, String ts ) { VowelExpert ve = new VowelExpert(); testNumeric( exp, ve.firstCharFrom(w,ts), "firstCharFrom(\""+w+"\",\""+ts+"\")" ); } static void testPigLatin() { System.out.println(" == toPigLatin =="); testPigLatin1( "enatorsay", "senator" ); testPigLatin1( "ahoo!yay", "yahoo!" ); testPigLatin1( "Aardvarkay", "Aardvark" ); testPigLatin1( "uh?hay", "huh?" ); testPigLatin1( "hrgh?ay", "hrgh?" ); testPigLatin1( "ogayay", "yoga" ); testPigLatin1( "asilYgdray", "Ygdrasil" ); testPigLatin1( "aay", "a" ); testPigLatin1( "zay", "z" ); testPigLatin1( "ay", "" ); } static void testPigLatin1( String exp, String w ) { VowelExpert ve = new VowelExpert(); testStrings( exp, ve.toPigLatin(w), "toPigLatin(\""+w+"\")" ); } static void testNumeric( int expected, int actual, String testName ) { if (actual==expected) { System.out.println( "pass: " + testName + " = " + actual ); } else { System.out.println( "FAIL: " + testName + " = " + actual + " != " + expected ); } } static void testStrings( String expected, String actual, String testName ) { if (actual.equals(expected)) { System.out.println( "pass: " + testName + " = " + actual ); } else { System.out.println( "FAIL: " + testName + " = " + actual + " != " + expected ); } } }