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 8dcf9d1 commit 1e6544e
Showing 1 changed file with 89 additions and 89 deletions.
178 changes: 89 additions & 89 deletions src/test/java/org/apache/commons/codec/language/SoundexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected Soundex createStringEncoder() {

@Test
public void testB650() throws EncoderException {
this.checkEncodingVariations("B650", new String[]{
checkEncodingVariations("B650", new String[]{
"BARHAM",
"BARONE",
"BARRON",
Expand Down Expand Up @@ -86,102 +86,102 @@ public void testB650() throws EncoderException {

@Test
public void testBadCharacters() {
assertEquals("H452", this.getStringEncoder().encode("HOL>MES"));
assertEquals("H452", getStringEncoder().encode("HOL>MES"));

}

@Test
public void testDifference() throws EncoderException {
// Edge cases
assertEquals(0, this.getStringEncoder().difference(null, null));
assertEquals(0, this.getStringEncoder().difference("", ""));
assertEquals(0, this.getStringEncoder().difference(" ", " "));
assertEquals(0, getStringEncoder().difference(null, null));
assertEquals(0, getStringEncoder().difference("", ""));
assertEquals(0, getStringEncoder().difference(" ", " "));
// Normal cases
assertEquals(4, this.getStringEncoder().difference("Smith", "Smythe"));
assertEquals(2, this.getStringEncoder().difference("Ann", "Andrew"));
assertEquals(1, this.getStringEncoder().difference("Margaret", "Andrew"));
assertEquals(0, this.getStringEncoder().difference("Janet", "Margaret"));
assertEquals(4, getStringEncoder().difference("Smith", "Smythe"));
assertEquals(2, getStringEncoder().difference("Ann", "Andrew"));
assertEquals(1, getStringEncoder().difference("Margaret", "Andrew"));
assertEquals(0, getStringEncoder().difference("Janet", "Margaret"));
// Examples from https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp
assertEquals(4, this.getStringEncoder().difference("Green", "Greene"));
assertEquals(0, this.getStringEncoder().difference("Blotchet-Halls", "Greene"));
assertEquals(4, getStringEncoder().difference("Green", "Greene"));
assertEquals(0, getStringEncoder().difference("Blotchet-Halls", "Greene"));
// Examples from https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp
assertEquals(4, this.getStringEncoder().difference("Smith", "Smythe"));
assertEquals(4, this.getStringEncoder().difference("Smithers", "Smythers"));
assertEquals(2, this.getStringEncoder().difference("Anothers", "Brothers"));
assertEquals(4, getStringEncoder().difference("Smith", "Smythe"));
assertEquals(4, getStringEncoder().difference("Smithers", "Smythers"));
assertEquals(2, getStringEncoder().difference("Anothers", "Brothers"));
}

@Test
public void testEncodeBasic() {
assertEquals("T235", this.getStringEncoder().encode("testing"));
assertEquals("T000", this.getStringEncoder().encode("The"));
assertEquals("Q200", this.getStringEncoder().encode("quick"));
assertEquals("B650", this.getStringEncoder().encode("brown"));
assertEquals("F200", this.getStringEncoder().encode("fox"));
assertEquals("J513", this.getStringEncoder().encode("jumped"));
assertEquals("O160", this.getStringEncoder().encode("over"));
assertEquals("T000", this.getStringEncoder().encode("the"));
assertEquals("L200", this.getStringEncoder().encode("lazy"));
assertEquals("D200", this.getStringEncoder().encode("dogs"));
assertEquals("T235", getStringEncoder().encode("testing"));
assertEquals("T000", getStringEncoder().encode("The"));
assertEquals("Q200", getStringEncoder().encode("quick"));
assertEquals("B650", getStringEncoder().encode("brown"));
assertEquals("F200", getStringEncoder().encode("fox"));
assertEquals("J513", getStringEncoder().encode("jumped"));
assertEquals("O160", getStringEncoder().encode("over"));
assertEquals("T000", getStringEncoder().encode("the"));
assertEquals("L200", getStringEncoder().encode("lazy"));
assertEquals("D200", getStringEncoder().encode("dogs"));
}

/**
* Examples from http://www.bradandkathy.com/genealogy/overviewofsoundex.html
*/
@Test
public void testEncodeBatch2() {
assertEquals("A462", this.getStringEncoder().encode("Allricht"));
assertEquals("E166", this.getStringEncoder().encode("Eberhard"));
assertEquals("E521", this.getStringEncoder().encode("Engebrethson"));
assertEquals("H512", this.getStringEncoder().encode("Heimbach"));
assertEquals("H524", this.getStringEncoder().encode("Hanselmann"));
assertEquals("H431", this.getStringEncoder().encode("Hildebrand"));
assertEquals("K152", this.getStringEncoder().encode("Kavanagh"));
assertEquals("L530", this.getStringEncoder().encode("Lind"));
assertEquals("L222", this.getStringEncoder().encode("Lukaschowsky"));
assertEquals("M235", this.getStringEncoder().encode("McDonnell"));
assertEquals("M200", this.getStringEncoder().encode("McGee"));
assertEquals("O155", this.getStringEncoder().encode("Opnian"));
assertEquals("O155", this.getStringEncoder().encode("Oppenheimer"));
assertEquals("R355", this.getStringEncoder().encode("Riedemanas"));
assertEquals("Z300", this.getStringEncoder().encode("Zita"));
assertEquals("Z325", this.getStringEncoder().encode("Zitzmeinn"));
assertEquals("A462", getStringEncoder().encode("Allricht"));
assertEquals("E166", getStringEncoder().encode("Eberhard"));
assertEquals("E521", getStringEncoder().encode("Engebrethson"));
assertEquals("H512", getStringEncoder().encode("Heimbach"));
assertEquals("H524", getStringEncoder().encode("Hanselmann"));
assertEquals("H431", getStringEncoder().encode("Hildebrand"));
assertEquals("K152", getStringEncoder().encode("Kavanagh"));
assertEquals("L530", getStringEncoder().encode("Lind"));
assertEquals("L222", getStringEncoder().encode("Lukaschowsky"));
assertEquals("M235", getStringEncoder().encode("McDonnell"));
assertEquals("M200", getStringEncoder().encode("McGee"));
assertEquals("O155", getStringEncoder().encode("Opnian"));
assertEquals("O155", getStringEncoder().encode("Oppenheimer"));
assertEquals("R355", getStringEncoder().encode("Riedemanas"));
assertEquals("Z300", getStringEncoder().encode("Zita"));
assertEquals("Z325", getStringEncoder().encode("Zitzmeinn"));
}

/**
* Examples from http://www.archives.gov/research_room/genealogy/census/soundex.html
*/
@Test
public void testEncodeBatch3() {
assertEquals("W252", this.getStringEncoder().encode("Washington"));
assertEquals("L000", this.getStringEncoder().encode("Lee"));
assertEquals("G362", this.getStringEncoder().encode("Gutierrez"));
assertEquals("P236", this.getStringEncoder().encode("Pfister"));
assertEquals("J250", this.getStringEncoder().encode("Jackson"));
assertEquals("T522", this.getStringEncoder().encode("Tymczak"));
assertEquals("W252", getStringEncoder().encode("Washington"));
assertEquals("L000", getStringEncoder().encode("Lee"));
assertEquals("G362", getStringEncoder().encode("Gutierrez"));
assertEquals("P236", getStringEncoder().encode("Pfister"));
assertEquals("J250", getStringEncoder().encode("Jackson"));
assertEquals("T522", getStringEncoder().encode("Tymczak"));
// For VanDeusen: D-250 (D, 2 for the S, 5 for the N, 0 added) is also
// possible.
assertEquals("V532", this.getStringEncoder().encode("VanDeusen"));
assertEquals("V532", getStringEncoder().encode("VanDeusen"));
}

/**
* Examples from: http://www.myatt.demon.co.uk/sxalg.htm
*/
@Test
public void testEncodeBatch4() {
assertEquals("H452", this.getStringEncoder().encode("HOLMES"));
assertEquals("A355", this.getStringEncoder().encode("ADOMOMI"));
assertEquals("V536", this.getStringEncoder().encode("VONDERLEHR"));
assertEquals("B400", this.getStringEncoder().encode("BALL"));
assertEquals("S000", this.getStringEncoder().encode("SHAW"));
assertEquals("J250", this.getStringEncoder().encode("JACKSON"));
assertEquals("S545", this.getStringEncoder().encode("SCANLON"));
assertEquals("S532", this.getStringEncoder().encode("SAINTJOHN"));
assertEquals("H452", getStringEncoder().encode("HOLMES"));
assertEquals("A355", getStringEncoder().encode("ADOMOMI"));
assertEquals("V536", getStringEncoder().encode("VONDERLEHR"));
assertEquals("B400", getStringEncoder().encode("BALL"));
assertEquals("S000", getStringEncoder().encode("SHAW"));
assertEquals("J250", getStringEncoder().encode("JACKSON"));
assertEquals("S545", getStringEncoder().encode("SCANLON"));
assertEquals("S532", getStringEncoder().encode("SAINTJOHN"));

}

@Test
public void testEncodeIgnoreApostrophes() throws EncoderException {
this.checkEncodingVariations("O165", new String[]{
checkEncodingVariations("O165", new String[]{
"OBrien",
"'OBrien",
"O'Brien",
Expand All @@ -198,7 +198,7 @@ public void testEncodeIgnoreApostrophes() throws EncoderException {
* @throws EncoderException for some failure scenarios */
@Test
public void testEncodeIgnoreHyphens() throws EncoderException {
this.checkEncodingVariations("K525", new String[]{
checkEncodingVariations("K525", new String[]{
"KINGSMITH",
"-KINGSMITH",
"K-INGSMITH",
Expand All @@ -214,7 +214,7 @@ public void testEncodeIgnoreHyphens() throws EncoderException {

@Test
public void testEncodeIgnoreTrimmable() {
assertEquals("W252", this.getStringEncoder().encode(" \t\n\r Washington \t\n\r "));
assertEquals("W252", getStringEncoder().encode(" \t\n\r Washington \t\n\r "));
}

@Test
Expand All @@ -240,10 +240,10 @@ public void testHWRuleEx1() {
// http://www.archives.gov/research_room/genealogy/census/soundex.html:
// Ashcraft is coded A-261 (A, 2 for the S, C ignored, 6 for the R, 1
// for the F). It is not coded A-226.
assertEquals("A261", this.getStringEncoder().encode("Ashcraft"));
assertEquals("A261", this.getStringEncoder().encode("Ashcroft"));
assertEquals("Y330", this.getStringEncoder().encode("yehudit"));
assertEquals("Y330", this.getStringEncoder().encode("yhwdyt"));
assertEquals("A261", getStringEncoder().encode("Ashcraft"));
assertEquals("A261", getStringEncoder().encode("Ashcroft"));
assertEquals("Y330", getStringEncoder().encode("yehudit"));
assertEquals("Y330", getStringEncoder().encode("yhwdyt"));
}

/**
Expand All @@ -253,8 +253,8 @@ public void testHWRuleEx1() {
*/
@Test
public void testHWRuleEx2() {
assertEquals("B312", this.getStringEncoder().encode("BOOTHDAVIS"));
assertEquals("B312", this.getStringEncoder().encode("BOOTH-DAVIS"));
assertEquals("B312", getStringEncoder().encode("BOOTHDAVIS"));
assertEquals("B312", getStringEncoder().encode("BOOTH-DAVIS"));
}

/**
Expand All @@ -263,10 +263,10 @@ public void testHWRuleEx2() {
* @throws EncoderException for some failure scenarios */
@Test
public void testHWRuleEx3() throws EncoderException {
assertEquals("S460", this.getStringEncoder().encode("Sgler"));
assertEquals("S460", this.getStringEncoder().encode("Swhgler"));
assertEquals("S460", getStringEncoder().encode("Sgler"));
assertEquals("S460", getStringEncoder().encode("Swhgler"));
// Also S460:
this.checkEncodingVariations("S460", new String[]{
checkEncodingVariations("S460", new String[]{
"SAILOR",
"SALYER",
"SAYLOR",
Expand All @@ -291,8 +291,8 @@ public void testHWRuleEx3() throws EncoderException {
*/
@Test
public void testMsSqlServer1() {
assertEquals("S530", this.getStringEncoder().encode("Smith"));
assertEquals("S530", this.getStringEncoder().encode("Smythe"));
assertEquals("S530", getStringEncoder().encode("Smith"));
assertEquals("S530", getStringEncoder().encode("Smythe"));
}

/**
Expand All @@ -303,23 +303,23 @@ public void testMsSqlServer1() {
* @throws EncoderException for some failure scenarios */
@Test
public void testMsSqlServer2() throws EncoderException {
this.checkEncodingVariations("E625", new String[]{"Erickson", "Erickson", "Erikson", "Ericson", "Ericksen", "Ericsen"});
checkEncodingVariations("E625", new String[]{"Erickson", "Erickson", "Erikson", "Ericson", "Ericksen", "Ericsen"});
}

/**
* Examples for MS SQLServer from https://databases.about.com/library/weekly/aa042901a.htm
*/
@Test
public void testMsSqlServer3() {
assertEquals("A500", this.getStringEncoder().encode("Ann"));
assertEquals("A536", this.getStringEncoder().encode("Andrew"));
assertEquals("J530", this.getStringEncoder().encode("Janet"));
assertEquals("M626", this.getStringEncoder().encode("Margaret"));
assertEquals("S315", this.getStringEncoder().encode("Steven"));
assertEquals("M240", this.getStringEncoder().encode("Michael"));
assertEquals("R163", this.getStringEncoder().encode("Robert"));
assertEquals("L600", this.getStringEncoder().encode("Laura"));
assertEquals("A500", this.getStringEncoder().encode("Anne"));
assertEquals("A500", getStringEncoder().encode("Ann"));
assertEquals("A536", getStringEncoder().encode("Andrew"));
assertEquals("J530", getStringEncoder().encode("Janet"));
assertEquals("M626", getStringEncoder().encode("Margaret"));
assertEquals("S315", getStringEncoder().encode("Steven"));
assertEquals("M240", getStringEncoder().encode("Michael"));
assertEquals("R163", getStringEncoder().encode("Robert"));
assertEquals("L600", getStringEncoder().encode("Laura"));
assertEquals("A500", getStringEncoder().encode("Anne"));
}

/**
Expand Down Expand Up @@ -383,12 +383,12 @@ public void testUsEnglishStatic() {
*/
@Test
public void testUsMappingEWithAcute() {
assertEquals("E000", this.getStringEncoder().encode("e"));
assertEquals("E000", getStringEncoder().encode("e"));
if (Character.isLetter('\u00e9')) { // e-acute
// uppercase E-acute
assertThrows(IllegalArgumentException.class, () -> getStringEncoder().encode("\u00e9"));
} else {
assertEquals("", this.getStringEncoder().encode("\u00e9"));
assertEquals("", getStringEncoder().encode("\u00e9"));
}
}

Expand All @@ -399,12 +399,12 @@ public void testUsMappingEWithAcute() {
*/
@Test
public void testUsMappingOWithDiaeresis() {
assertEquals("O000", this.getStringEncoder().encode("o"));
assertEquals("O000", getStringEncoder().encode("o"));
if (Character.isLetter('\u00f6')) { // o-umlaut
// uppercase O-umlaut
assertThrows(IllegalArgumentException.class, () -> getStringEncoder().encode("\u00f6"));
} else {
assertEquals("", this.getStringEncoder().encode("\u00f6"));
assertEquals("", getStringEncoder().encode("\u00f6"));
}
}

Expand All @@ -413,11 +413,11 @@ public void testUsMappingOWithDiaeresis() {
*/
@Test
public void testWikipediaAmericanSoundex() {
assertEquals("R163", this.getStringEncoder().encode("Robert"));
assertEquals("R163", this.getStringEncoder().encode("Rupert"));
assertEquals("A261", this.getStringEncoder().encode("Ashcraft"));
assertEquals("A261", this.getStringEncoder().encode("Ashcroft"));
assertEquals("T522", this.getStringEncoder().encode("Tymczak"));
assertEquals("P236", this.getStringEncoder().encode("Pfister"));
assertEquals("R163", getStringEncoder().encode("Robert"));
assertEquals("R163", getStringEncoder().encode("Rupert"));
assertEquals("A261", getStringEncoder().encode("Ashcraft"));
assertEquals("A261", getStringEncoder().encode("Ashcroft"));
assertEquals("T522", getStringEncoder().encode("Tymczak"));
assertEquals("P236", getStringEncoder().encode("Pfister"));
}
}

0 comments on commit 1e6544e

Please sign in to comment.