1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.codec.language;
19
20 import static org.junit.jupiter.api.Assertions.assertFalse;
21 import static org.junit.jupiter.api.Assertions.assertTrue;
22
23 import org.apache.commons.codec.AbstractStringEncoderTest;
24 import org.apache.commons.codec.EncoderException;
25 import org.junit.jupiter.api.Test;
26
27
28
29
30 public class Caverphone2Test extends AbstractStringEncoderTest<Caverphone2> {
31
32 @Override
33 protected Caverphone2 createStringEncoder() {
34 return new Caverphone2();
35 }
36
37
38
39
40
41
42
43 @Test
44 public void testCaverphoneRevisitedCommonCodeAT11111111() throws EncoderException {
45 this.checkEncodingVariations("AT11111111", new String[]{
46 "add",
47 "aid",
48 "at",
49 "art",
50 "eat",
51 "earth",
52 "head",
53 "hit",
54 "hot",
55 "hold",
56 "hard",
57 "heart",
58 "it",
59 "out",
60 "old"});
61 }
62
63
64
65
66
67 @Test
68 public void testCaverphoneRevisitedExamples() throws EncoderException {
69 final String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}};
70 this.checkEncodings(data);
71 }
72
73
74
75
76
77 @Test
78 public void testCaverphoneRevisitedRandomNameKLN1111111() throws EncoderException {
79 this.checkEncodingVariations("KLN1111111", new String[]{
80 "Cailean",
81 "Calan",
82 "Calen",
83 "Callahan",
84 "Callan",
85 "Callean",
86 "Carleen",
87 "Carlen",
88 "Carlene",
89 "Carlin",
90 "Carline",
91 "Carlyn",
92 "Carlynn",
93 "Carlynne",
94 "Charlean",
95 "Charleen",
96 "Charlene",
97 "Charline",
98 "Cherlyn",
99 "Chirlin",
100 "Clein",
101 "Cleon",
102 "Cline",
103 "Cohleen",
104 "Colan",
105 "Coleen",
106 "Colene",
107 "Colin",
108 "Colleen",
109 "Collen",
110 "Collin",
111 "Colline",
112 "Colon",
113 "Cullan",
114 "Cullen",
115 "Cullin",
116 "Gaelan",
117 "Galan",
118 "Galen",
119 "Garlan",
120 "Garlen",
121 "Gaulin",
122 "Gayleen",
123 "Gaylene",
124 "Giliane",
125 "Gillan",
126 "Gillian",
127 "Glen",
128 "Glenn",
129 "Glyn",
130 "Glynn",
131 "Gollin",
132 "Gorlin",
133 "Kalin",
134 "Karlan",
135 "Karleen",
136 "Karlen",
137 "Karlene",
138 "Karlin",
139 "Karlyn",
140 "Kaylyn",
141 "Keelin",
142 "Kellen",
143 "Kellene",
144 "Kellyann",
145 "Kellyn",
146 "Khalin",
147 "Kilan",
148 "Kilian",
149 "Killen",
150 "Killian",
151 "Killion",
152 "Klein",
153 "Kleon",
154 "Kline",
155 "Koerlin",
156 "Kylen",
157 "Kylynn",
158 "Quillan",
159 "Quillon",
160 "Qulllon",
161 "Xylon"});
162 }
163
164
165
166
167
168 @Test
169 public void testCaverphoneRevisitedRandomNameTN11111111() throws EncoderException {
170 this.checkEncodingVariations("TN11111111", new String[]{
171 "Dan",
172 "Dane",
173 "Dann",
174 "Darn",
175 "Daune",
176 "Dawn",
177 "Ddene",
178 "Dean",
179 "Deane",
180 "Deanne",
181 "DeeAnn",
182 "Deeann",
183 "Deeanne",
184 "Deeyn",
185 "Den",
186 "Dene",
187 "Denn",
188 "Deonne",
189 "Diahann",
190 "Dian",
191 "Diane",
192 "Diann",
193 "Dianne",
194 "Diannne",
195 "Dine",
196 "Dion",
197 "Dione",
198 "Dionne",
199 "Doane",
200 "Doehne",
201 "Don",
202 "Donn",
203 "Doone",
204 "Dorn",
205 "Down",
206 "Downe",
207 "Duane",
208 "Dun",
209 "Dunn",
210 "Duyne",
211 "Dyan",
212 "Dyane",
213 "Dyann",
214 "Dyanne",
215 "Dyun",
216 "Tan",
217 "Tann",
218 "Teahan",
219 "Ten",
220 "Tenn",
221 "Terhune",
222 "Thain",
223 "Thaine",
224 "Thane",
225 "Thanh",
226 "Thayne",
227 "Theone",
228 "Thin",
229 "Thorn",
230 "Thorne",
231 "Thun",
232 "Thynne",
233 "Tien",
234 "Tine",
235 "Tjon",
236 "Town",
237 "Towne",
238 "Turne",
239 "Tyne"});
240 }
241
242
243
244
245
246 @Test
247 public void testCaverphoneRevisitedRandomNameTTA1111111() throws EncoderException {
248 this.checkEncodingVariations("TTA1111111", new String[]{
249 "Darda",
250 "Datha",
251 "Dedie",
252 "Deedee",
253 "Deerdre",
254 "Deidre",
255 "Deirdre",
256 "Detta",
257 "Didi",
258 "Didier",
259 "Dido",
260 "Dierdre",
261 "Dieter",
262 "Dita",
263 "Ditter",
264 "Dodi",
265 "Dodie",
266 "Dody",
267 "Doherty",
268 "Dorthea",
269 "Dorthy",
270 "Doti",
271 "Dotti",
272 "Dottie",
273 "Dotty",
274 "Doty",
275 "Doughty",
276 "Douty",
277 "Dowdell",
278 "Duthie",
279 "Tada",
280 "Taddeo",
281 "Tadeo",
282 "Tadio",
283 "Tati",
284 "Teador",
285 "Tedda",
286 "Tedder",
287 "Teddi",
288 "Teddie",
289 "Teddy",
290 "Tedi",
291 "Tedie",
292 "Teeter",
293 "Teodoor",
294 "Teodor",
295 "Terti",
296 "Theda",
297 "Theodor",
298 "Theodore",
299 "Theta",
300 "Thilda",
301 "Thordia",
302 "Tilda",
303 "Tildi",
304 "Tildie",
305 "Tildy",
306 "Tita",
307 "Tito",
308 "Tjader",
309 "Toddie",
310 "Toddy",
311 "Torto",
312 "Tuddor",
313 "Tudor",
314 "Turtle",
315 "Tuttle",
316 "Tutto"});
317 }
318
319
320
321
322
323 @Test
324 public void testCaverphoneRevisitedRandomWords() throws EncoderException {
325 this.checkEncodingVariations("RTA1111111", new String[]{"rather", "ready", "writer"});
326 this.checkEncoding("SSA1111111", "social");
327 this.checkEncodingVariations("APA1111111", new String[]{"able", "appear"});
328 }
329
330 @Test
331 public void testEndMb() throws EncoderException {
332 final String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}};
333 this.checkEncodings(data);
334 }
335
336
337 @Test
338 public void testIsCaverphoneEquals() throws EncoderException {
339 final Caverphone2 caverphone = new Caverphone2();
340 assertFalse(caverphone.isEncodeEqual("Peter", "Stevenson"), "Caverphone encodings should not be equal");
341 assertTrue(caverphone.isEncodeEqual("Peter", "Peady"), "Caverphone encodings should be equal");
342 }
343
344 @Test
345 public void testSpecificationExamples() throws EncoderException {
346 final String[][] data = {
347 {"Peter", "PTA1111111"},
348 {"ready", "RTA1111111"},
349 {"social", "SSA1111111"},
350 {"able", "APA1111111"},
351 {"Tedder", "TTA1111111"},
352 {"Karleen", "KLN1111111"},
353 {"Dyun", "TN11111111"}};
354 this.checkEncodings(data);
355 }
356
357 }