commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1636488 - /commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java
Date Tue, 04 Nov 2014 02:23:04 GMT
Author: ggregory
Date: Tue Nov  4 02:23:03 2014
New Revision: 1636488

URL: http://svn.apache.org/r1636488
Log:
Minor refactoring.

Modified:
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java?rev=1636488&r1=1636487&r2=1636488&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DaitchMokotoffSoundexTest.java
Tue Nov  4 02:23:03 2014
@@ -36,13 +36,21 @@ public class DaitchMokotoffSoundexTest e
         return new DaitchMokotoffSoundex();
     }
 
+    private String soundex(String source) {
+        return getStringEncoder().soundex(source);
+    }
+
+    private String encode(String source) {
+        return getStringEncoder().encode(source);
+    }
+
     @Test
     public void testAccentedCharacterFolding() {
-        Assert.assertEquals("294795", this.getStringEncoder().soundex("Straßburg"));
-        Assert.assertEquals("294795", this.getStringEncoder().soundex("Strasburg"));
+        Assert.assertEquals("294795", soundex("Straßburg"));
+        Assert.assertEquals("294795", soundex("Strasburg"));
 
-        Assert.assertEquals("095600", this.getStringEncoder().soundex("Éregon"));
-        Assert.assertEquals("095600", this.getStringEncoder().soundex("Eregon"));
+        Assert.assertEquals("095600", soundex("Éregon"));
+        Assert.assertEquals("095600", soundex("Eregon"));
     }
 
     @Test
@@ -51,25 +59,25 @@ public class DaitchMokotoffSoundexTest e
         // A-KS-S-O-L
         // 0-54-4---8 -> wrong
         // 0-54-----8 -> correct
-        Assert.assertEquals("054800", this.getStringEncoder().soundex("AKSSOL"));
+        Assert.assertEquals("054800", soundex("AKSSOL"));
 
         // GERSCHFELD
         // G-E-RS-CH-F-E-L-D
         // 5--4/94-5/4-7-8-3 -> wrong
         // 5--4/94-5/--7-8-3 -> correct
-        Assert.assertEquals("547830|545783|594783|594578", this.getStringEncoder().soundex("GERSCHFELD"));
+        Assert.assertEquals("547830|545783|594783|594578", soundex("GERSCHFELD"));
     }
 
     public void testEncodeBasic() {
         // same as above, but without branching
-        Assert.assertEquals("097400", this.getStringEncoder().encode("AUERBACH"));
-        Assert.assertEquals("097400", this.getStringEncoder().encode("OHRBACH"));
-        Assert.assertEquals("874400", this.getStringEncoder().encode("LIPSHITZ"));
-        Assert.assertEquals("874400", this.getStringEncoder().encode("LIPPSZYC"));
-        Assert.assertEquals("876450", this.getStringEncoder().encode("LEWINSKY"));
-        Assert.assertEquals("876450", this.getStringEncoder().encode("LEVINSKI"));
-        Assert.assertEquals("486740", this.getStringEncoder().encode("SZLAMAWICZ"));
-        Assert.assertEquals("486740", this.getStringEncoder().encode("SHLAMOVITZ"));
+        Assert.assertEquals("097400", encode("AUERBACH"));
+        Assert.assertEquals("097400", encode("OHRBACH"));
+        Assert.assertEquals("874400", encode("LIPSHITZ"));
+        Assert.assertEquals("874400", encode("LIPPSZYC"));
+        Assert.assertEquals("876450", encode("LEWINSKY"));
+        Assert.assertEquals("876450", encode("LEVINSKI"));
+        Assert.assertEquals("486740", encode("SZLAMAWICZ"));
+        Assert.assertEquals("486740", encode("SHLAMOVITZ"));
     }
 
     @Test
@@ -91,8 +99,8 @@ public class DaitchMokotoffSoundexTest e
 
     @Test
     public void testEncodeIgnoreTrimmable() {
-        Assert.assertEquals("746536", this.getStringEncoder().encode(" \t\n\r Washington
\t\n\r "));
-        Assert.assertEquals("746536", this.getStringEncoder().encode("Washington"));
+        Assert.assertEquals("746536", encode(" \t\n\r Washington \t\n\r "));
+        Assert.assertEquals("746536", encode("Washington"));
     }
 
     /**
@@ -100,24 +108,24 @@ public class DaitchMokotoffSoundexTest e
      */
     @Test
     public void testSoundexBasic() {
-        Assert.assertEquals("583600", this.getStringEncoder().soundex("GOLDEN"));
-        Assert.assertEquals("087930", this.getStringEncoder().soundex("Alpert"));
-        Assert.assertEquals("791900", this.getStringEncoder().soundex("Breuer"));
-        Assert.assertEquals("579000", this.getStringEncoder().soundex("Haber"));
-        Assert.assertEquals("665600", this.getStringEncoder().soundex("Mannheim"));
-        Assert.assertEquals("664000", this.getStringEncoder().soundex("Mintz"));
-        Assert.assertEquals("370000", this.getStringEncoder().soundex("Topf"));
-        Assert.assertEquals("586660", this.getStringEncoder().soundex("Kleinmann"));
-        Assert.assertEquals("769600", this.getStringEncoder().soundex("Ben Aron"));
-
-        Assert.assertEquals("097400|097500", this.getStringEncoder().soundex("AUERBACH"));
-        Assert.assertEquals("097400|097500", this.getStringEncoder().soundex("OHRBACH"));
-        Assert.assertEquals("874400", this.getStringEncoder().soundex("LIPSHITZ"));
-        Assert.assertEquals("874400|874500", this.getStringEncoder().soundex("LIPPSZYC"));
-        Assert.assertEquals("876450", this.getStringEncoder().soundex("LEWINSKY"));
-        Assert.assertEquals("876450", this.getStringEncoder().soundex("LEVINSKI"));
-        Assert.assertEquals("486740", this.getStringEncoder().soundex("SZLAMAWICZ"));
-        Assert.assertEquals("486740", this.getStringEncoder().soundex("SHLAMOVITZ"));
+        Assert.assertEquals("583600", soundex("GOLDEN"));
+        Assert.assertEquals("087930", soundex("Alpert"));
+        Assert.assertEquals("791900", soundex("Breuer"));
+        Assert.assertEquals("579000", soundex("Haber"));
+        Assert.assertEquals("665600", soundex("Mannheim"));
+        Assert.assertEquals("664000", soundex("Mintz"));
+        Assert.assertEquals("370000", soundex("Topf"));
+        Assert.assertEquals("586660", soundex("Kleinmann"));
+        Assert.assertEquals("769600", soundex("Ben Aron"));
+
+        Assert.assertEquals("097400|097500", soundex("AUERBACH"));
+        Assert.assertEquals("097400|097500", soundex("OHRBACH"));
+        Assert.assertEquals("874400", soundex("LIPSHITZ"));
+        Assert.assertEquals("874400|874500", soundex("LIPPSZYC"));
+        Assert.assertEquals("876450", soundex("LEWINSKY"));
+        Assert.assertEquals("876450", soundex("LEVINSKI"));
+        Assert.assertEquals("486740", soundex("SZLAMAWICZ"));
+        Assert.assertEquals("486740", soundex("SHLAMOVITZ"));
     }
 
     /**
@@ -125,15 +133,14 @@ public class DaitchMokotoffSoundexTest e
      */
     @Test
     public void testSoundexBasic2() {
-        Assert.assertEquals("467000|567000", this.getStringEncoder().soundex("Ceniow"));
-        Assert.assertEquals("467000", this.getStringEncoder().soundex("Tsenyuv"));
-        Assert.assertEquals("587400|587500", this.getStringEncoder().soundex("Holubica"));
-        Assert.assertEquals("587400", this.getStringEncoder().soundex("Golubitsa"));
-        Assert.assertEquals("746480|794648", this.getStringEncoder().soundex("Przemysl"));
-        Assert.assertEquals("746480", this.getStringEncoder().soundex("Pshemeshil"));
-        Assert.assertEquals("944744|944745|944754|944755|945744|945745|945754|945755",
-                this.getStringEncoder().soundex("Rosochowaciec"));
-        Assert.assertEquals("945744", this.getStringEncoder().soundex("Rosokhovatsets"));
+        Assert.assertEquals("467000|567000", soundex("Ceniow"));
+        Assert.assertEquals("467000", soundex("Tsenyuv"));
+        Assert.assertEquals("587400|587500", soundex("Holubica"));
+        Assert.assertEquals("587400", soundex("Golubitsa"));
+        Assert.assertEquals("746480|794648", soundex("Przemysl"));
+        Assert.assertEquals("746480", soundex("Pshemeshil"));
+        Assert.assertEquals("944744|944745|944754|944755|945744|945745|945754|945755", soundex("Rosochowaciec"));
+        Assert.assertEquals("945744", soundex("Rosokhovatsets"));
     }
 
     /**
@@ -141,19 +148,19 @@ public class DaitchMokotoffSoundexTest e
      */
     @Test
     public void testSoundexBasic3() {
-        Assert.assertEquals("734000|739400", this.getStringEncoder().soundex("Peters"));
-        Assert.assertEquals("734600|739460", this.getStringEncoder().soundex("Peterson"));
-        Assert.assertEquals("645740", this.getStringEncoder().soundex("Moskowitz"));
-        Assert.assertEquals("645740", this.getStringEncoder().soundex("Moskovitz"));
-        Assert.assertEquals("154600|145460|454600|445460", this.getStringEncoder().soundex("Jackson"));
-        Assert.assertEquals("154654|154645|154644|145465|145464|454654|454645|454644|445465|445464",
this
-                .getStringEncoder().soundex("Jackson-Jackson"));
+        Assert.assertEquals("734000|739400", soundex("Peters"));
+        Assert.assertEquals("734600|739460", soundex("Peterson"));
+        Assert.assertEquals("645740", soundex("Moskowitz"));
+        Assert.assertEquals("645740", soundex("Moskovitz"));
+        Assert.assertEquals("154600|145460|454600|445460", soundex("Jackson"));
+        Assert.assertEquals("154654|154645|154644|145465|145464|454654|454645|454644|445465|445464",
+                soundex("Jackson-Jackson"));
     }
 
     @Test
     public void testSpecialRomanianCharacters() {
-        Assert.assertEquals("364000|464000", this.getStringEncoder().soundex("Å£amas"));
// t-cedilla
-        Assert.assertEquals("364000|464000", this.getStringEncoder().soundex("țamas"));
// t-comma
+        Assert.assertEquals("364000|464000", soundex("Å£amas")); // t-cedilla
+        Assert.assertEquals("364000|464000", soundex("țamas")); // t-comma
     }
 
 }



Mime
View raw message