commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tobr...@apache.org
Subject cvs commit: jakarta-commons/codec/src/test/org/apache/commons/codec/language MetaphoneTest.java RefinedSoundexTest.java SoundexTest.java
Date Sun, 18 Apr 2004 21:34:16 GMT
tobrien     2004/04/18 14:34:16

  Modified:    codec/src/test/org/apache/commons/codec/language
                        MetaphoneTest.java RefinedSoundexTest.java
                        SoundexTest.java
  Log:
  Increased unit test coverage on Metaphone and RefinedSoundex
  
  Revision  Changes    Path
  1.11      +75 -2     jakarta-commons/codec/src/test/org/apache/commons/codec/language/MetaphoneTest.java
  
  Index: MetaphoneTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/codec/src/test/org/apache/commons/codec/language/MetaphoneTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MetaphoneTest.java	17 Mar 2004 19:28:37 -0000	1.10
  +++ MetaphoneTest.java	18 Apr 2004 21:34:16 -0000	1.11
  @@ -40,7 +40,8 @@
       public void assertIsMetaphoneEqual(String source, String[] matches) {
           // match source to all matches
           for (int i = 0; i < matches.length; i++) {
  -            assertTrue(this.getMetaphone().isMetaphoneEqual(source, matches[i]));
  +            assertTrue("Source: " + source + ", should have same Metaphone as: " + matches[i],
  +                       this.getMetaphone().isMetaphoneEqual(source, matches[i]));
           }
           // match to each other
           for (int i = 0; i < matches.length; i++) {
  @@ -374,6 +375,7 @@
       }
   
       public void testMetaphone() {
  +		assertEquals("HL", this.getMetaphone().metaphone("howl"));
           assertEquals("TSTN", this.getMetaphone().metaphone("testing"));
           assertEquals("0", this.getMetaphone().metaphone("The"));
           assertEquals("KK", this.getMetaphone().metaphone("quick"));
  @@ -385,6 +387,77 @@
           assertEquals("LS", this.getMetaphone().metaphone("lazy"));
           assertEquals("TKS", this.getMetaphone().metaphone("dogs"));
       }
  +	
  +	public void testWordEndingInMB() {
  +		assertEquals( "KM", this.getMetaphone().metaphone("COMB") );
  +		assertEquals( "TM", this.getMetaphone().metaphone("TOMB") );
  +		assertEquals( "WM", this.getMetaphone().metaphone("WOMB") );
  +	}
  +
  +	public void testDiscardOfSCEOrSCIOrSCY() {
  +		assertEquals( "SNS", this.getMetaphone().metaphone("SCIENCE") );
  +		assertEquals( "SN", this.getMetaphone().metaphone("SCENE") );
  +		assertEquals( "S", this.getMetaphone().metaphone("SCY") );
  +	}
  +
  +	public void testWordsWithCIA() {
  +		assertEquals( "XP", this.getMetaphone().metaphone("CIAPO") );
  +	}
  +
  +	public void testTranslateOfSCHAndCH() {
  +		assertEquals( "SKTL", this.getMetaphone().metaphone("SCHEDULE") );
  +		assertEquals( "SKMT", this.getMetaphone().metaphone("SCHEMATIC") );
  +
  +		assertEquals( "KRKT", this.getMetaphone().metaphone("CHARACTER") );
  +		assertEquals( "TX", this.getMetaphone().metaphone("TEACH") );
  +	}
  +
  +	public void testTranslateToJOfDGEOrDGIOrDGY() {
  +		assertEquals( "TJ", this.getMetaphone().metaphone("DODGY") );
  +		assertEquals( "TJ", this.getMetaphone().metaphone("DODGE") );
  +		assertEquals( "AJMT", this.getMetaphone().metaphone("ADGIEMTI") );
  +	}
  +
  +	public void testDiscardOfSilentHAfterG() {
  +		assertEquals( "KNT", this.getMetaphone().metaphone("GHENT") );
  +		assertEquals( "B", this.getMetaphone().metaphone("BAUGH") );
  +	}
  +
  +	public void testDiscardOfSilentGN() {
  +		assertEquals( "N", this.getMetaphone().metaphone("GNU") );
  +		assertEquals( "SNT", this.getMetaphone().metaphone("SIGNED") );
  +	}
  +
  +	public void testPHTOF() {
  +		assertEquals( "FX", this.getMetaphone().metaphone("PHISH") );
  +	}
  +
  +	public void testSHAndSIOAndSIAToX() {
  +		assertEquals( "XT", this.getMetaphone().metaphone("SHOT") );
  +		assertEquals( "OTXN", this.getMetaphone().metaphone("ODSIAN") );
  +		assertEquals( "PLXN", this.getMetaphone().metaphone("PULSION") );
  +	}
  +
  +	public void testTIOAndTIAToX() {
  +		assertEquals( "OX", this.getMetaphone().metaphone("OTIA") );
  +		assertEquals( "PRXN", this.getMetaphone().metaphone("PORTION") );
  +	}
  +
  +	public void testTCH() {
  +		assertEquals( "RX", this.getMetaphone().metaphone("RETCH") );
  +		assertEquals( "WX", this.getMetaphone().metaphone("WATCH") );
  +	}
  +
  +	public void testExceedLength() {
  +		// should be AKSKS, but istruncated by Max Code Length
  +		assertEquals( "AKSK", this.getMetaphone().metaphone("AXEAXE") );
  +	}
  +
  +	public void testSetMaxLengthWithTruncation() {
  +		// should be AKSKS, but istruncated by Max Code Length
  +		this.getMetaphone().setMaxCodeLen( 6 );
  +		assertEquals( "AKSKSK", this.getMetaphone().metaphone("AXEAXEAXE") );
  +	}
   
       public void validateFixture(String[][] pairs) {
           if (pairs.length == 0) {
  
  
  
  1.10      +6 -1      jakarta-commons/codec/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java
  
  Index: RefinedSoundexTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/codec/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RefinedSoundexTest.java	21 Mar 2004 01:30:11 -0000	1.9
  +++ RefinedSoundexTest.java	18 Apr 2004 21:34:16 -0000	1.10
  @@ -103,4 +103,9 @@
           assertEquals("L7050", this.getEncoder().encode("lazy"));
           assertEquals("D6043", this.getEncoder().encode("dogs"));
       }
  +
  +	public void testGetMappingCodeNonLetter() {
  +		char code = this.getEncoder().getMappingCode('#');
  +		assertEquals( "Code does not equals zero", 0, (int) code);
  +	}
   }
  
  
  
  1.16      +6 -1      jakarta-commons/codec/src/test/org/apache/commons/codec/language/SoundexTest.java
  
  Index: SoundexTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/codec/src/test/org/apache/commons/codec/language/SoundexTest.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SoundexTest.java	9 Apr 2004 22:46:08 -0000	1.15
  +++ SoundexTest.java	18 Apr 2004 21:34:16 -0000	1.16
  @@ -208,6 +208,11 @@
   
       }
   
  +	public void testBadCharacters() {
  +		assertEquals("H452", this.getEncoder().encode("HOL>MES"));
  +
  +	}
  +
       public void testEncodeIgnoreApostrophes() {
           this.encodeAll(new String[] { "OBrien", "'OBrien", "O'Brien", "OB'rien", "OBr'ien",
"OBri'en", "OBrie'n", "OBrien'" }, "O165");
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message