Skip to content

Commit 86beeaf

Browse files
committed
Refactor test for less test fixture construction noise.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1298651 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0980312 commit 86beeaf

1 file changed

Lines changed: 52 additions & 57 deletions

File tree

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

Lines changed: 52 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -156,63 +156,58 @@ public void testDropBy2() throws EncoderException {
156156
// 8. Collapse all strings of repeated characters
157157
// 9. Add original first character of name as first character of key
158158

159-
List<String[]> testValues =
160-
Arrays.asList(
161-
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
162-
// 1. Transcode first characters of name
163-
new String[] { "MACINTOSH", "MCANT" },
164-
// violates 4j: the second N should not be added, as the first
165-
// key char is already a N
166-
new String[] { "KNUTH", "NAT" }, // Original: NNAT; modified: NATH
167-
// O and E are transcoded to A because of rule 4a
168-
// H also to A because of rule 4h
169-
// the N gets mysteriously lost, maybe because of a wrongly implemented rule 4h
170-
// that skips the next char in such a case?
171-
// the remaining A is removed because of rule 7
172-
new String[] { "KOEHN", "CAN" }, // Original: C
173-
// violates 4j: see also KNUTH
174-
new String[] { "PHILLIPSON", "FALAPSAN" }, // Original: FFALAP[SAN]
175-
// violates 4j: see also KNUTH
176-
new String[] { "PFEISTER", "FASTAR" }, // Original: FFASTA[R]
177-
// violates 4j: see also KNUTH
178-
new String[] { "SCHOENHOEFT", "SANAFT" }, // Original: SSANAF[T]
179-
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
180-
// 2.Transcode last characters of name:
181-
new String[] { "MCKEE", "MCY" },
182-
new String[] { "MACKIE", "MCY" },
183-
new String[] { "HEITSCHMIDT", "HATSNAD" },
184-
new String[] { "BART", "BAD" },
185-
new String[] { "HURD", "HAD" },
186-
new String[] { "HUNT", "HAD" },
187-
new String[] { "WESTERLUND", "WASTARLAD" },
188-
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
189-
// 4. Transcode remaining characters by following these rules, incrementing by one character each time:
190-
new String[] { "CASSTEVENS", "CASTAFAN" },
191-
new String[] { "VASQUEZ", "VASG" },
192-
new String[] { "FRAZIER", "FRASAR" },
193-
new String[] { "BOWMAN", "BANAN" },
194-
new String[] { "MCKNIGHT", "MCNAGT" },
195-
new String[] { "RICKERT", "RACAD" },
196-
// violates 5: the last S is not removed
197-
// when comparing to DEUTS, which is phonetically similar
198-
// the result it also DAT, which is correct for DEUTSCH too imo
199-
new String[] { "DEUTSCH", "DAT" }, // Original: DATS
200-
new String[] { "WESTPHAL", "WASTFAL" },
201-
// violates 4h: the H should be transcoded to S and thus ignored as
202-
// the first key character is also S
203-
new String[] { "SHRIVER", "SRAVAR" }, // Original: SHRAVA[R]
204-
// same as KOEHN, the L gets mysteriously lost
205-
new String[] { "KUHL", "CAL" }, // Original: C
206-
new String[] { "RAWSON", "RASAN" },
207-
// If last character is S, remove it
208-
new String[] { "JILES", "JAL" },
209-
// violates 6: if the last two characters are AY, remove A
210-
new String[] { "CARRAWAY", "CARY" }, // Original: CARAY
211-
new String[] { "YAMADA", "YANAD" });
212-
213-
for (String[] arr : testValues) {
214-
Assert.assertEquals("Problem with " + arr[0], arr[1], this.fullNysiis.encode(arr[0]));
215-
}
159+
this.assertEncodings(
160+
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
161+
// 1. Transcode first characters of name
162+
new String[] { "MACINTOSH", "MCANT" },
163+
// violates 4j: the second N should not be added, as the first
164+
// key char is already a N
165+
new String[] { "KNUTH", "NAT" }, // Original: NNAT; modified: NATH
166+
// O and E are transcoded to A because of rule 4a
167+
// H also to A because of rule 4h
168+
// the N gets mysteriously lost, maybe because of a wrongly implemented rule 4h
169+
// that skips the next char in such a case?
170+
// the remaining A is removed because of rule 7
171+
new String[] { "KOEHN", "CAN" }, // Original: C
172+
// violates 4j: see also KNUTH
173+
new String[] { "PHILLIPSON", "FALAPSAN" }, // Original: FFALAP[SAN]
174+
// violates 4j: see also KNUTH
175+
new String[] { "PFEISTER", "FASTAR" }, // Original: FFASTA[R]
176+
// violates 4j: see also KNUTH
177+
new String[] { "SCHOENHOEFT", "SANAFT" }, // Original: SSANAF[T]
178+
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
179+
// 2.Transcode last characters of name:
180+
new String[] { "MCKEE", "MCY" },
181+
new String[] { "MACKIE", "MCY" },
182+
new String[] { "HEITSCHMIDT", "HATSNAD" },
183+
new String[] { "BART", "BAD" },
184+
new String[] { "HURD", "HAD" },
185+
new String[] { "HUNT", "HAD" },
186+
new String[] { "WESTERLUND", "WASTARLAD" },
187+
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
188+
// 4. Transcode remaining characters by following these rules, incrementing by one character each time:
189+
new String[] { "CASSTEVENS", "CASTAFAN" },
190+
new String[] { "VASQUEZ", "VASG" },
191+
new String[] { "FRAZIER", "FRASAR" },
192+
new String[] { "BOWMAN", "BANAN" },
193+
new String[] { "MCKNIGHT", "MCNAGT" },
194+
new String[] { "RICKERT", "RACAD" },
195+
// violates 5: the last S is not removed
196+
// when comparing to DEUTS, which is phonetically similar
197+
// the result it also DAT, which is correct for DEUTSCH too imo
198+
new String[] { "DEUTSCH", "DAT" }, // Original: DATS
199+
new String[] { "WESTPHAL", "WASTFAL" },
200+
// violates 4h: the H should be transcoded to S and thus ignored as
201+
// the first key character is also S
202+
new String[] { "SHRIVER", "SRAVAR" }, // Original: SHRAVA[R]
203+
// same as KOEHN, the L gets mysteriously lost
204+
new String[] { "KUHL", "CAL" }, // Original: C
205+
new String[] { "RAWSON", "RASAN" },
206+
// If last character is S, remove it
207+
new String[] { "JILES", "JAL" },
208+
// violates 6: if the last two characters are AY, remove A
209+
new String[] { "CARRAWAY", "CARY" }, // Original: CARAY
210+
new String[] { "YAMADA", "YANAD" });
216211
}
217212

218213
@Test

0 commit comments

Comments
 (0)