Skip to content

Commit 57381ce

Browse files
committed
1 parent 921a971 commit 57381ce

1 file changed

Lines changed: 302 additions & 7 deletions

File tree

src/test/org/apache/commons/codec/language/CaverphoneTest.java

Lines changed: 302 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.commons.codec.language;
1919

20+
import junit.framework.Assert;
21+
2022
import org.apache.commons.codec.EncoderException;
2123
import org.apache.commons.codec.StringEncoder;
2224
import org.apache.commons.codec.StringEncoderAbstractTest;
@@ -35,6 +37,306 @@ protected StringEncoder createStringEncoder() {
3537
return new Caverphone();
3638
}
3739

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

61-
// Caverphone Revisited
62-
public void testIsCaverphoneEquals() {
63-
Caverphone caverphone = new Caverphone();
64-
assertFalse("Caverphone encodings should not be equal", caverphone.isCaverphoneEqual("Peter", "Stevenson"));
65-
assertTrue("Caverphone encodings should be equal", caverphone.isCaverphoneEqual("Peter", "Peady"));
66-
}
67-
68363
}

0 commit comments

Comments
 (0)