|
|
@@ -1,85 +1,146 @@
|
|
|
1
|
+import org.junit.Before;
|
|
|
2
|
+import org.junit.Ignore;
|
|
1
|
3
|
import org.junit.Test;
|
|
2
|
|
-import org.junit.runner.RunWith;
|
|
3
|
|
-import org.junit.runners.Parameterized;
|
|
4
|
|
-
|
|
5
|
|
-import java.util.Arrays;
|
|
6
|
|
-import java.util.Collection;
|
|
7
|
4
|
|
|
8
|
5
|
import static org.junit.Assert.assertEquals;
|
|
9
|
6
|
|
|
10
|
|
-@RunWith(Parameterized.class)
|
|
11
|
7
|
public class PigLatinTranslatorTest {
|
|
12
|
8
|
|
|
13
|
|
- private String englishPhrase;
|
|
14
|
|
- private String pigLatinTranslation;
|
|
|
9
|
+ private PigLatinTranslator pigLatinTranslator;
|
|
|
10
|
+
|
|
|
11
|
+ @Before
|
|
|
12
|
+ public void setup() {
|
|
|
13
|
+ pigLatinTranslator = new PigLatinTranslator();
|
|
|
14
|
+ }
|
|
15
|
15
|
|
|
16
|
|
- @Parameterized.Parameters(name = "{index}: expected \"{0}\" to translate to the pig latin phrase \"{1}\"")
|
|
17
|
|
- public static Collection<Object[]> data() {
|
|
18
|
|
- return Arrays.asList(new Object[][]{
|
|
19
|
|
- // Ay is added to words that start with vowels
|
|
20
|
|
- {"apple", "appleay"},
|
|
21
|
|
- {"ear", "earay"},
|
|
22
|
|
- {"igloo", "iglooay"},
|
|
23
|
|
- {"object", "objectay"},
|
|
24
|
|
- {"under", "underay"},
|
|
|
16
|
+ @Test
|
|
|
17
|
+ public void testWordBeginningWithA() {
|
|
|
18
|
+ assertEquals("appleay", pigLatinTranslator.translate("apple"));
|
|
|
19
|
+ }
|
|
25
|
20
|
|
|
26
|
|
- // Word beginning with vowel follwed by a 'qu'
|
|
27
|
|
- {"equal", "equalay"},
|
|
|
21
|
+ @Ignore("Remove to run test")
|
|
|
22
|
+ @Test
|
|
|
23
|
+ public void testWordBeginningWithE() {
|
|
|
24
|
+ assertEquals("earay", pigLatinTranslator.translate("ear"));
|
|
|
25
|
+ }
|
|
28
|
26
|
|
|
29
|
|
- // First letter and ay are moved to the end of words that start with consonants
|
|
30
|
|
- {"pig", "igpay"},
|
|
31
|
|
- {"koala", "oalakay"},
|
|
32
|
|
- {"xenon", "enonxay"},
|
|
|
27
|
+ @Ignore("Remove to run test")
|
|
|
28
|
+ @Test
|
|
|
29
|
+ public void testWordBeginningWithI() {
|
|
|
30
|
+ assertEquals("iglooay", pigLatinTranslator.translate("igloo"));
|
|
|
31
|
+ }
|
|
33
|
32
|
|
|
34
|
|
- // Word beginning with 'q' without a following 'u'
|
|
35
|
|
- {"qat", "atqay"},
|
|
|
33
|
+ @Ignore("Remove to run test")
|
|
|
34
|
+ @Test
|
|
|
35
|
+ public void testWordBeginningWithO() {
|
|
|
36
|
+ assertEquals("objectay", pigLatinTranslator.translate("object"));
|
|
|
37
|
+ }
|
|
36
|
38
|
|
|
37
|
|
- // Ch is treated like a single consonant
|
|
38
|
|
- {"chair", "airchay"},
|
|
|
39
|
+ @Ignore("Remove to run test")
|
|
|
40
|
+ @Test
|
|
|
41
|
+ public void testWordBeginningWithU() {
|
|
|
42
|
+ assertEquals("underay", pigLatinTranslator.translate("under"));
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+ @Ignore("Remove to run test")
|
|
|
46
|
+ @Test
|
|
|
47
|
+ public void testWordBeginningWithVowelAndFollowedByQu() {
|
|
|
48
|
+ assertEquals("equalay", pigLatinTranslator.translate("equal"));
|
|
|
49
|
+ }
|
|
|
50
|
+
|
|
|
51
|
+ @Ignore("Remove to run test")
|
|
|
52
|
+ @Test
|
|
|
53
|
+ public void testWordBeginningWithP() {
|
|
|
54
|
+ assertEquals("igpay", pigLatinTranslator.translate("pig"));
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+ @Ignore("Remove to run test")
|
|
|
58
|
+ @Test
|
|
|
59
|
+ public void testWordBeginningWithK() {
|
|
|
60
|
+ assertEquals("oalakay", pigLatinTranslator.translate("koala"));
|
|
|
61
|
+ }
|
|
|
62
|
+ @Ignore("Remove to run test")
|
|
|
63
|
+ @Test
|
|
|
64
|
+ public void testWordBeginningWithX() {
|
|
|
65
|
+ assertEquals("enonxay", pigLatinTranslator.translate("xenon"));
|
|
|
66
|
+ }
|
|
39
|
67
|
|
|
40
|
|
- // Qu is treated like a single consonant
|
|
41
|
|
- {"queen", "eenquay"},
|
|
|
68
|
+ @Ignore("Remove to run test")
|
|
|
69
|
+ @Test
|
|
|
70
|
+ public void testWordBeginningWithQWithoutAFollowingU() {
|
|
|
71
|
+ assertEquals("atqay", pigLatinTranslator.translate("qat"));
|
|
|
72
|
+ }
|
|
42
|
73
|
|
|
43
|
|
- // Qu and a single preceding consonant are treated like a single consonant
|
|
44
|
|
- {"square", "aresquay"},
|
|
|
74
|
+ @Ignore("Remove to run test")
|
|
|
75
|
+ @Test
|
|
|
76
|
+ public void testChTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
77
|
+ assertEquals("airchay", pigLatinTranslator.translate("chair"));
|
|
|
78
|
+ }
|
|
45
|
79
|
|
|
46
|
|
- // Th is treated like a single consonant
|
|
47
|
|
- {"therapy", "erapythay"},
|
|
|
80
|
+ @Ignore("Remove to run test")
|
|
|
81
|
+ @Test
|
|
|
82
|
+ public void testQuTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
83
|
+ assertEquals("eenquay", pigLatinTranslator.translate("queen"));
|
|
|
84
|
+ }
|
|
48
|
85
|
|
|
49
|
|
- // Thr is treated like a single consonant
|
|
50
|
|
- {"thrush", "ushthray"},
|
|
|
86
|
+ @Ignore("Remove to run test")
|
|
|
87
|
+ @Test
|
|
|
88
|
+ public void testQuAndAPrecedingConsonantTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
89
|
+ assertEquals("aresquay", pigLatinTranslator.translate("square"));
|
|
|
90
|
+ }
|
|
51
|
91
|
|
|
52
|
|
- // Sch is treated like a single consonant
|
|
53
|
|
- {"school", "oolschay"},
|
|
|
92
|
+ @Ignore("Remove to run test")
|
|
|
93
|
+ @Test
|
|
|
94
|
+ public void testThTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
95
|
+ assertEquals("erapythay", pigLatinTranslator.translate("therapy"));
|
|
|
96
|
+ }
|
|
54
|
97
|
|
|
55
|
|
- // Yt is treated like a single vowel
|
|
56
|
|
- {"yttria", "yttriaay"},
|
|
|
98
|
+ @Ignore("Remove to run test")
|
|
|
99
|
+ @Test
|
|
|
100
|
+ public void testThrTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
101
|
+ assertEquals("ushthray", pigLatinTranslator.translate("thrush"));
|
|
|
102
|
+ }
|
|
57
|
103
|
|
|
58
|
|
- // Xr is treated like a single vowel
|
|
59
|
|
- {"xray", "xrayay"},
|
|
|
104
|
+ @Ignore("Remove to run test")
|
|
|
105
|
+ @Test
|
|
|
106
|
+ public void testSchTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
107
|
+ assertEquals("oolschay", pigLatinTranslator.translate("school"));
|
|
|
108
|
+ }
|
|
60
|
109
|
|
|
61
|
|
- // 'Y' is treated like a consonant at the beginning of a word
|
|
62
|
|
- {"yellow", "ellowyay"},
|
|
|
110
|
+ @Ignore("Remove to run test")
|
|
|
111
|
+ @Test
|
|
|
112
|
+ public void testYtTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
113
|
+ assertEquals("yttriaay", pigLatinTranslator.translate("yttria"));
|
|
|
114
|
+ }
|
|
63
|
115
|
|
|
64
|
|
- // 'Y' is treated like a vowel at the end of a consonant cluster
|
|
65
|
|
- {"rhythm", "ythmrhay"},
|
|
|
116
|
+ @Ignore("Remove to run test")
|
|
|
117
|
+ @Test
|
|
|
118
|
+ public void testXrTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
119
|
+ assertEquals("xrayay", pigLatinTranslator.translate("xray"));
|
|
|
120
|
+ }
|
|
66
|
121
|
|
|
67
|
|
- // 'Y' as second letter in a two letter word
|
|
68
|
|
- {"my", "ymay"},
|
|
|
122
|
+ @Ignore("Remove to run test")
|
|
|
123
|
+ @Test
|
|
|
124
|
+ public void testYTreatedLikeAConsonantAtTheBeginningOfAWord() {
|
|
|
125
|
+ assertEquals("ellowyay", pigLatinTranslator.translate("yellow"));
|
|
|
126
|
+ }
|
|
69
|
127
|
|
|
70
|
|
- // Phrases are translated
|
|
71
|
|
- {"quick fast run", "ickquay astfay unray"}
|
|
72
|
|
- });
|
|
|
128
|
+ @Ignore("Remove to run test")
|
|
|
129
|
+ @Test
|
|
|
130
|
+ public void testYTreatedLikeAVowelAtTheEndOfAConsonantCluster() {
|
|
|
131
|
+ assertEquals("ythmrhay", pigLatinTranslator.translate("rhythm"));
|
|
73
|
132
|
}
|
|
74
|
133
|
|
|
75
|
|
- public PigLatinTranslatorTest(String englishPhrase, String pigLatinTranslation) {
|
|
76
|
|
- this.englishPhrase = englishPhrase;
|
|
77
|
|
- this.pigLatinTranslation = pigLatinTranslation;
|
|
|
134
|
+ @Ignore("Remove to run test")
|
|
|
135
|
+ @Test
|
|
|
136
|
+ public void testYAsSecondLetterInTwoLetterWord() {
|
|
|
137
|
+ assertEquals("ymay", pigLatinTranslator.translate("my"));
|
|
78
|
138
|
}
|
|
79
|
139
|
|
|
|
140
|
+ @Ignore("Remove to run test")
|
|
80
|
141
|
@Test
|
|
81
|
|
- public void test() {
|
|
82
|
|
- assertEquals(pigLatinTranslation, new PigLatinTranslator().translate(englishPhrase));
|
|
|
142
|
+ public void testAWholePhrase() {
|
|
|
143
|
+ assertEquals("ickquay astfay unray", pigLatinTranslator.translate("quick fast run"));
|
|
83
|
144
|
}
|
|
84
|
145
|
|
|
85
|
146
|
}
|