Skip to content

Commit

Permalink
Remove redundant keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jul 9, 2024
1 parent 9b82536 commit dbe8f00
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions src/test/java/org/apache/commons/codec/language/MetaphoneTest.java
Original file line number Diff line number Diff line change
@@ -31,24 +31,24 @@ public class MetaphoneTest extends AbstractStringEncoderTest<Metaphone> {
public void assertIsMetaphoneEqual(final String source, final String[] matches) {
// match source to all matches
for (final String matche : matches) {
assertTrue(this.getStringEncoder().isMetaphoneEqual(source, matche), "Source: " + source + ", should have same Metaphone as: " + matche);
assertTrue(getStringEncoder().isMetaphoneEqual(source, matche), "Source: " + source + ", should have same Metaphone as: " + matche);
}
// match to each other
for (final String matche : matches) {
for (final String matche2 : matches) {
assertTrue(this.getStringEncoder().isMetaphoneEqual(matche, matche2));
assertTrue(getStringEncoder().isMetaphoneEqual(matche, matche2));
}
}
}

public void assertMetaphoneEqual(final String[][] pairs) {
this.validateFixture(pairs);
validateFixture(pairs);
for (final String[] pair : pairs) {
final String name0 = pair[0];
final String name1 = pair[1];
final String failMsg = "Expected match between " + name0 + " and " + name1;
assertTrue(this.getStringEncoder().isMetaphoneEqual(name0, name1), failMsg);
assertTrue(this.getStringEncoder().isMetaphoneEqual(name1, name0), failMsg);
assertTrue(getStringEncoder().isMetaphoneEqual(name0, name1), failMsg);
assertTrue(getStringEncoder().isMetaphoneEqual(name1, name0), failMsg);
}
}

@@ -59,43 +59,43 @@ protected Metaphone createStringEncoder() {

@Test
public void testDiscardOfSCEOrSCIOrSCY() {
assertEquals("SNS", this.getStringEncoder().metaphone("SCIENCE"));
assertEquals("SN", this.getStringEncoder().metaphone("SCENE"));
assertEquals("S", this.getStringEncoder().metaphone("SCY"));
assertEquals("SNS", getStringEncoder().metaphone("SCIENCE"));
assertEquals("SN", getStringEncoder().metaphone("SCENE"));
assertEquals("S", getStringEncoder().metaphone("SCY"));
}

@Test
public void testDiscardOfSilentGN() {
// NOTE: This does not test for silent GN, but for starting with GN
assertEquals("N", this.getStringEncoder().metaphone("GNU"));
assertEquals("N", getStringEncoder().metaphone("GNU"));

// NOTE: Trying to test for GNED, but expected code does not appear to execute
assertEquals("SNT", this.getStringEncoder().metaphone("SIGNED"));
assertEquals("SNT", getStringEncoder().metaphone("SIGNED"));
}

@Test
public void testDiscardOfSilentHAfterG() {
assertEquals("KNT", this.getStringEncoder().metaphone("GHENT"));
assertEquals("B", this.getStringEncoder().metaphone("BAUGH"));
assertEquals("KNT", getStringEncoder().metaphone("GHENT"));
assertEquals("B", getStringEncoder().metaphone("BAUGH"));
}

@Test
public void testExceedLength() {
// should be AKSKS, but is truncated by Max Code Length
assertEquals("AKSK", this.getStringEncoder().metaphone("AXEAXE"));
assertEquals("AKSK", getStringEncoder().metaphone("AXEAXE"));
}

@Test
public void testIsMetaphoneEqual1() {
this.assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { "caSe", "cAsE" }, { "quick", "cookie" } });
assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { "caSe", "cAsE" }, { "quick", "cookie" } });
}

/**
* Matches computed from http://www.lanw.com/java/phonetic/default.htm
*/
@Test
public void testIsMetaphoneEqual2() {
this.assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, });
assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, });
}

/**
@@ -105,7 +105,7 @@ public void testIsMetaphoneEqual2() {
*/
@Test
public void testIsMetaphoneEqualAero() {
this.assertIsMetaphoneEqual("Aero", new String[] { "Eure" });
assertIsMetaphoneEqual("Aero", new String[] { "Eure" });
}

/**
@@ -115,15 +115,15 @@ public void testIsMetaphoneEqualAero() {
*/
@Test
public void testIsMetaphoneEqualAlbert() {
this.assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" });
assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" });
}

/**
* Match data computed from http://www.lanw.com/java/phonetic/default.htm
*/
@Test
public void testIsMetaphoneEqualGary() {
this.assertIsMetaphoneEqual("Gary",
assertIsMetaphoneEqual("Gary",
new String[] { "Cahra", "Cara", "Carey", "Cari", "Caria", "Carie", "Caro", "Carree", "Carri", "Carrie", "Carry", "Cary", "Cora", "Corey",
"Cori", "Corie", "Correy", "Corri", "Corrie", "Corry", "Cory", "Gray", "Kara", "Kare", "Karee", "Kari", "Karia", "Karie", "Karrah",
"Karrie", "Karry", "Kary", "Keri", "Kerri", "Kerrie", "Kerry", "Kira", "Kiri", "Kora", "Kore", "Kori", "Korie", "Korrie", "Korry" });
@@ -134,7 +134,7 @@ public void testIsMetaphoneEqualGary() {
*/
@Test
public void testIsMetaphoneEqualJohn() {
this.assertIsMetaphoneEqual("John",
assertIsMetaphoneEqual("John",
new String[] { "Gena", "Gene", "Genia", "Genna", "Genni", "Gennie", "Genny", "Giana", "Gianna", "Gina", "Ginni", "Ginnie", "Ginny", "Jaine",
"Jan", "Jana", "Jane", "Janey", "Jania", "Janie", "Janna", "Jany", "Jayne", "Jean", "Jeana", "Jeane", "Jeanie", "Jeanna", "Jeanne",
"Jeannie", "Jen", "Jena", "Jeni", "Jenn", "Jenna", "Jennee", "Jenni", "Jennie", "Jenny", "Jinny", "Jo Ann", "Jo-Ann", "Jo-Anne", "Joan",
@@ -149,7 +149,7 @@ public void testIsMetaphoneEqualJohn() {
*/
@Test
public void testIsMetaphoneEqualKnight() {
this.assertIsMetaphoneEqual("Knight", new String[] { "Hynda", "Nada", "Nadia", "Nady", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta",
assertIsMetaphoneEqual("Knight", new String[] { "Hynda", "Nada", "Nadia", "Nady", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta",
"Netti", "Nettie", "Netty", "Nita", "Nydia" });
}

@@ -158,7 +158,7 @@ public void testIsMetaphoneEqualKnight() {
*/
@Test
public void testIsMetaphoneEqualMary() {
this.assertIsMetaphoneEqual("Mary", new String[] { "Mair", "Maire", "Mara", "Mareah", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara",
assertIsMetaphoneEqual("Mary", new String[] { "Mair", "Maire", "Mara", "Mareah", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara",
"Merrie", "Merry", "Mira", "Moira", "Mora", "Moria", "Moyra", "Muire", "Myra", "Myrah" });
}

@@ -167,31 +167,31 @@ public void testIsMetaphoneEqualMary() {
*/
@Test
public void testIsMetaphoneEqualParis() {
this.assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" });
assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" });
}

/**
* Match data computed from http://www.lanw.com/java/phonetic/default.htm
*/
@Test
public void testIsMetaphoneEqualPeter() {
this.assertIsMetaphoneEqual("Peter", new String[] { "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro", "Piotr" });
assertIsMetaphoneEqual("Peter", new String[] { "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro", "Piotr" });
}

/**
* Match data computed from http://www.lanw.com/java/phonetic/default.htm
*/
@Test
public void testIsMetaphoneEqualRay() {
this.assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" });
assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" });
}

/**
* Match data computed from http://www.lanw.com/java/phonetic/default.htm
*/
@Test
public void testIsMetaphoneEqualSusan() {
this.assertIsMetaphoneEqual("Susan",
assertIsMetaphoneEqual("Susan",
new String[] { "Siusan", "Sosanna", "Susan", "Susana", "Susann", "Susanna", "Susannah", "Susanne", "Suzann", "Suzanna", "Suzanne", "Zuzana" });
}

@@ -202,7 +202,7 @@ public void testIsMetaphoneEqualSusan() {
*/
@Test
public void testIsMetaphoneEqualWhite() {
this.assertIsMetaphoneEqual("White",
assertIsMetaphoneEqual("White",
new String[] { "Wade", "Wait", "Waite", "Wat", "Whit", "Wiatt", "Wit", "Wittie", "Witty", "Wood", "Woodie", "Woody" });
}

@@ -213,77 +213,77 @@ public void testIsMetaphoneEqualWhite() {
*/
@Test
public void testIsMetaphoneEqualWright() {
this.assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" });
assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" });
}

/**
* Match data computed from http://www.lanw.com/java/phonetic/default.htm
*/
@Test
public void testIsMetaphoneEqualXalan() {
this.assertIsMetaphoneEqual("Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" });
assertIsMetaphoneEqual("Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" });
}

@Test
public void testMetaphone() {
assertEquals("HL", this.getStringEncoder().metaphone("howl"));
assertEquals("TSTN", this.getStringEncoder().metaphone("testing"));
assertEquals("0", this.getStringEncoder().metaphone("The"));
assertEquals("KK", this.getStringEncoder().metaphone("quick"));
assertEquals("BRN", this.getStringEncoder().metaphone("brown"));
assertEquals("FKS", this.getStringEncoder().metaphone("fox"));
assertEquals("JMPT", this.getStringEncoder().metaphone("jumped"));
assertEquals("OFR", this.getStringEncoder().metaphone("over"));
assertEquals("0", this.getStringEncoder().metaphone("the"));
assertEquals("LS", this.getStringEncoder().metaphone("lazy"));
assertEquals("TKS", this.getStringEncoder().metaphone("dogs"));
assertEquals("HL", getStringEncoder().metaphone("howl"));
assertEquals("TSTN", getStringEncoder().metaphone("testing"));
assertEquals("0", getStringEncoder().metaphone("The"));
assertEquals("KK", getStringEncoder().metaphone("quick"));
assertEquals("BRN", getStringEncoder().metaphone("brown"));
assertEquals("FKS", getStringEncoder().metaphone("fox"));
assertEquals("JMPT", getStringEncoder().metaphone("jumped"));
assertEquals("OFR", getStringEncoder().metaphone("over"));
assertEquals("0", getStringEncoder().metaphone("the"));
assertEquals("LS", getStringEncoder().metaphone("lazy"));
assertEquals("TKS", getStringEncoder().metaphone("dogs"));
}

@Test
public void testPHTOF() {
assertEquals("FX", this.getStringEncoder().metaphone("PHISH"));
assertEquals("FX", getStringEncoder().metaphone("PHISH"));
}

@Test
public void testSetMaxLengthWithTruncation() {
// should be AKSKS, but istruncated by Max Code Length
this.getStringEncoder().setMaxCodeLen(6);
assertEquals("AKSKSK", this.getStringEncoder().metaphone("AXEAXEAXE"));
getStringEncoder().setMaxCodeLen(6);
assertEquals("AKSKSK", getStringEncoder().metaphone("AXEAXEAXE"));
}

@Test
public void testSHAndSIOAndSIAToX() {
assertEquals("XT", this.getStringEncoder().metaphone("SHOT"));
assertEquals("OTXN", this.getStringEncoder().metaphone("ODSIAN"));
assertEquals("PLXN", this.getStringEncoder().metaphone("PULSION"));
assertEquals("XT", getStringEncoder().metaphone("SHOT"));
assertEquals("OTXN", getStringEncoder().metaphone("ODSIAN"));
assertEquals("PLXN", getStringEncoder().metaphone("PULSION"));
}

@Test
public void testTCH() {
assertEquals("RX", this.getStringEncoder().metaphone("RETCH"));
assertEquals("WX", this.getStringEncoder().metaphone("WATCH"));
assertEquals("RX", getStringEncoder().metaphone("RETCH"));
assertEquals("WX", getStringEncoder().metaphone("WATCH"));
}

@Test
public void testTIOAndTIAToX() {
assertEquals("OX", this.getStringEncoder().metaphone("OTIA"));
assertEquals("PRXN", this.getStringEncoder().metaphone("PORTION"));
assertEquals("OX", getStringEncoder().metaphone("OTIA"));
assertEquals("PRXN", getStringEncoder().metaphone("PORTION"));
}

@Test
public void testTranslateOfSCHAndCH() {
assertEquals("SKTL", this.getStringEncoder().metaphone("SCHEDULE"));
assertEquals("SKMT", this.getStringEncoder().metaphone("SCHEMATIC"));
assertEquals("SKTL", getStringEncoder().metaphone("SCHEDULE"));
assertEquals("SKMT", getStringEncoder().metaphone("SCHEMATIC"));

assertEquals("KRKT", this.getStringEncoder().metaphone("CHARACTER"));
assertEquals("TX", this.getStringEncoder().metaphone("TEACH"));
assertEquals("KRKT", getStringEncoder().metaphone("CHARACTER"));
assertEquals("TX", getStringEncoder().metaphone("TEACH"));
}

@Test
public void testTranslateToJOfDGEOrDGIOrDGY() {
assertEquals("TJ", this.getStringEncoder().metaphone("DODGY"));
assertEquals("TJ", this.getStringEncoder().metaphone("DODGE"));
assertEquals("AJMT", this.getStringEncoder().metaphone("ADGIEMTI"));
assertEquals("TJ", getStringEncoder().metaphone("DODGY"));
assertEquals("TJ", getStringEncoder().metaphone("DODGE"));
assertEquals("AJMT", getStringEncoder().metaphone("ADGIEMTI"));
}

/**
@@ -292,19 +292,19 @@ public void testTranslateToJOfDGEOrDGIOrDGY() {
@Test
public void testWhy() {
// PHP returns "H". The original metaphone returns an empty string.
assertEquals("", this.getStringEncoder().metaphone("WHY"));
assertEquals("", getStringEncoder().metaphone("WHY"));
}

@Test
public void testWordEndingInMB() {
assertEquals("KM", this.getStringEncoder().metaphone("COMB"));
assertEquals("TM", this.getStringEncoder().metaphone("TOMB"));
assertEquals("WM", this.getStringEncoder().metaphone("WOMB"));
assertEquals("KM", getStringEncoder().metaphone("COMB"));
assertEquals("TM", getStringEncoder().metaphone("TOMB"));
assertEquals("WM", getStringEncoder().metaphone("WOMB"));
}

@Test
public void testWordsWithCIA() {
assertEquals("XP", this.getStringEncoder().metaphone("CIAPO"));
assertEquals("XP", getStringEncoder().metaphone("CIAPO"));
}

public void validateFixture(final String[][] pairs) {

0 comments on commit dbe8f00

Please sign in to comment.