Skip to content

Commit 82eb1a8

Browse files
committed
Test variations that encode to 67: "Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major"
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1073465 13f79535-47bb-0310-9956-ffa450edef68
1 parent 22a832d commit 82eb1a8

1 file changed

Lines changed: 28 additions & 23 deletions

File tree

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

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ public void checkEncoding(String expected, String source) {
3434
Assert.assertEquals("Source: " + source, expected, this.colognePhonetic.encode(source));
3535
}
3636

37+
private void checkEncodings(String[][] data) {
38+
for (int i = 0; i < data.length; i++) {
39+
this.checkEncoding(data[i][1], data[i][0]);
40+
}
41+
}
42+
43+
private void checkEncodingVariations(String expected, String data[]) {
44+
for (int i = 0; i < data.length; i++) {
45+
this.checkEncoding(expected, data[i]);
46+
}
47+
}
48+
3749
protected StringEncoder createEncoder() {
3850
return new ColognePhonetic();
3951
}
@@ -77,18 +89,12 @@ public void testEdgeCases() {
7789
{"acl", "085"},
7890
{"mn", "6"},
7991
{"r", "7"}};
80-
81-
for (int i = 0; i < data.length; i++) {
82-
Assert.assertEquals("Failed to correctly convert element of index: " + i, data[i][1],
83-
this.colognePhonetic.colognePhonetic(data[i][0]));
84-
}
92+
this.checkEncodings(data);
8593
}
8694

8795
public void testExamples() {
8896
String[][] data = {{"Müller-Lüdenscheidt", "65752682"}, {"Breschnew", "17863"}, {"Wikipedia", "3412"}};
89-
for (int i = 0; i < data.length; i++) {
90-
this.checkEncoding(data[i][1], data[i][0]);
91-
}
97+
this.checkEncodings(data);
9298
}
9399

94100
public void testHyphen() {
@@ -119,28 +125,27 @@ public void testIsCologneEqualsPhpData() {
119125
* Test data from http://repo.magdev.de/src/Text_ColognePhonetic-0.2.2/test/Text_ColognePhoneticTest.php
120126
*/
121127
public void testPhpData() {
122-
String[][] data = {
123-
{"peter", "127"},
124-
{"pharma", "376"},
125-
{"bergisch-gladbach", "174845214"},
126-
{"mönchengladbach", "664645214"},
127-
// {"deutsch", "288"}, // Probably a bug
128+
String[][] data = {{"peter", "127"}, {"pharma", "376"}, {"bergisch-gladbach", "174845214"}, {"mönchengladbach", "664645214"},
129+
// {"deutsch", "288"}, // Probably a bug
128130
{"deutz", "28"},
129-
// {"hamburg", "6174"},
130-
// {"hannover", "637"},
131-
// {"christstollen", "4788256"},
131+
// {"hamburg", "6174"},
132+
// {"hannover", "637"},
133+
// {"christstollen", "4788256"},
132134
{"Xanthippe", "48621"},
133135
{"Zacharias", "8478"},
134-
// {"Holzbau", "581"},
135-
// {"matsch", "688"},
136+
// {"Holzbau", "581"},
137+
// {"matsch", "688"},
136138
{"matz", "68"},
137139
{"Arbeitsamt", "071862"},
138140
{"Eberhard", "01772"},
139141
{"Eberhardt", "01772"},
140-
// {"heithabu", "21"},
142+
// {"heithabu", "21"},
141143
{"Müller-Lüdenscheidt", "65752682"},};
142-
for (int i = 0; i < data.length; i++) {
143-
this.checkEncoding(data[i][1], data[i][0]);
144-
}
144+
this.checkEncodings(data);
145+
}
146+
147+
public void testVariations() {
148+
String data[] = {"Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major"};
149+
this.checkEncodingVariations("67", data);
145150
}
146151
}

0 commit comments

Comments
 (0)