tracks/java/exercises/pig-latin/src/test/java/PigLatinTranslatorTest.java in trackler-2.2.1.105 vs tracks/java/exercises/pig-latin/src/test/java/PigLatinTranslatorTest.java in trackler-2.2.1.106

- old
+ new

@@ -1,85 +1,146 @@ +import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import java.util.Arrays; -import java.util.Collection; - import static org.junit.Assert.assertEquals; -@RunWith(Parameterized.class) public class PigLatinTranslatorTest { - private String englishPhrase; - private String pigLatinTranslation; + private PigLatinTranslator pigLatinTranslator; - @Parameterized.Parameters(name = "{index}: expected \"{0}\" to translate to the pig latin phrase \"{1}\"") - public static Collection<Object[]> data() { - return Arrays.asList(new Object[][]{ - // Ay is added to words that start with vowels - {"apple", "appleay"}, - {"ear", "earay"}, - {"igloo", "iglooay"}, - {"object", "objectay"}, - {"under", "underay"}, + @Before + public void setup() { + pigLatinTranslator = new PigLatinTranslator(); + } - // Word beginning with vowel follwed by a 'qu' - {"equal", "equalay"}, + @Test + public void testWordBeginningWithA() { + assertEquals("appleay", pigLatinTranslator.translate("apple")); + } - // First letter and ay are moved to the end of words that start with consonants - {"pig", "igpay"}, - {"koala", "oalakay"}, - {"xenon", "enonxay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithE() { + assertEquals("earay", pigLatinTranslator.translate("ear")); + } - // Word beginning with 'q' without a following 'u' - {"qat", "atqay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithI() { + assertEquals("iglooay", pigLatinTranslator.translate("igloo")); + } - // Ch is treated like a single consonant - {"chair", "airchay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithO() { + assertEquals("objectay", pigLatinTranslator.translate("object")); + } - // Qu is treated like a single consonant - {"queen", "eenquay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithU() { + assertEquals("underay", pigLatinTranslator.translate("under")); + } - // Qu and a single preceding consonant are treated like a single consonant - {"square", "aresquay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithVowelAndFollowedByQu() { + assertEquals("equalay", pigLatinTranslator.translate("equal")); + } - // Th is treated like a single consonant - {"therapy", "erapythay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithP() { + assertEquals("igpay", pigLatinTranslator.translate("pig")); + } - // Thr is treated like a single consonant - {"thrush", "ushthray"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithK() { + assertEquals("oalakay", pigLatinTranslator.translate("koala")); + } + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithX() { + assertEquals("enonxay", pigLatinTranslator.translate("xenon")); + } - // Sch is treated like a single consonant - {"school", "oolschay"}, + @Ignore("Remove to run test") + @Test + public void testWordBeginningWithQWithoutAFollowingU() { + assertEquals("atqay", pigLatinTranslator.translate("qat")); + } - // Yt is treated like a single vowel - {"yttria", "yttriaay"}, + @Ignore("Remove to run test") + @Test + public void testChTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("airchay", pigLatinTranslator.translate("chair")); + } - // Xr is treated like a single vowel - {"xray", "xrayay"}, + @Ignore("Remove to run test") + @Test + public void testQuTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("eenquay", pigLatinTranslator.translate("queen")); + } - // 'Y' is treated like a consonant at the beginning of a word - {"yellow", "ellowyay"}, + @Ignore("Remove to run test") + @Test + public void testQuAndAPrecedingConsonantTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("aresquay", pigLatinTranslator.translate("square")); + } - // 'Y' is treated like a vowel at the end of a consonant cluster - {"rhythm", "ythmrhay"}, + @Ignore("Remove to run test") + @Test + public void testThTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("erapythay", pigLatinTranslator.translate("therapy")); + } - // 'Y' as second letter in a two letter word - {"my", "ymay"}, + @Ignore("Remove to run test") + @Test + public void testThrTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("ushthray", pigLatinTranslator.translate("thrush")); + } - // Phrases are translated - {"quick fast run", "ickquay astfay unray"} - }); + @Ignore("Remove to run test") + @Test + public void testSchTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("oolschay", pigLatinTranslator.translate("school")); } - public PigLatinTranslatorTest(String englishPhrase, String pigLatinTranslation) { - this.englishPhrase = englishPhrase; - this.pigLatinTranslation = pigLatinTranslation; + @Ignore("Remove to run test") + @Test + public void testYtTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("yttriaay", pigLatinTranslator.translate("yttria")); } + @Ignore("Remove to run test") @Test - public void test() { - assertEquals(pigLatinTranslation, new PigLatinTranslator().translate(englishPhrase)); + public void testXrTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("xrayay", pigLatinTranslator.translate("xray")); + } + + @Ignore("Remove to run test") + @Test + public void testYTreatedLikeAConsonantAtTheBeginningOfAWord() { + assertEquals("ellowyay", pigLatinTranslator.translate("yellow")); + } + + @Ignore("Remove to run test") + @Test + public void testYTreatedLikeAVowelAtTheEndOfAConsonantCluster() { + assertEquals("ythmrhay", pigLatinTranslator.translate("rhythm")); + } + + @Ignore("Remove to run test") + @Test + public void testYAsSecondLetterInTwoLetterWord() { + assertEquals("ymay", pigLatinTranslator.translate("my")); + } + + @Ignore("Remove to run test") + @Test + public void testAWholePhrase() { + assertEquals("ickquay astfay unray", pigLatinTranslator.translate("quick fast run")); } }