commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec TestEncoder.java TestRefinedSoundex.java TestSoundex.java TestAll.java TestMetaphone.java
Date Mon, 18 Nov 2002 13:00:26 GMT
rwaldhoff    2002/11/18 05:00:26

  Modified:    codec/src/java/org/apache/commons/codec RefinedSoundex.java
                        Soundex.java
               codec/src/test/org/apache/commons/codec TestAll.java
                        TestMetaphone.java
  Added:       codec/src/test/org/apache/commons/codec TestEncoder.java
                        TestRefinedSoundex.java TestSoundex.java
  Log:
  more tests
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-commons-sandbox/codec/src/java/org/apache/commons/codec/RefinedSoundex.java
  
  Index: RefinedSoundex.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec/src/java/org/apache/commons/codec/RefinedSoundex.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RefinedSoundex.java	18 Nov 2002 12:41:24 -0000	1.2
  +++ RefinedSoundex.java	18 Nov 2002 13:00:25 -0000	1.3
  @@ -1,3 +1,3 @@
   /* ====================================================================
 * The Apache Software
License, Version 1.1
 *
 * Copyright (c) 2002 The Apache Software Foundation.  All rights
* reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification,
are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions
of source code must retain the above copyright
 *    notice, this list of conditions and the
following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in
 *    the documentation
and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation
included with the redistribution,
 *    if any, must include the following acknowledgment:
*       "This product includes software developed by the
 *        Apache Software Foundation
(http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software
itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The
names "Apache" and "Apache Software Foundation" and
 *    "Apache Commons" must not be used
to endorse or promote products
 *    derived from this software without prior written permission.
For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived
from this software may not be called "Apache",
 *    "Apache Turbine", nor may "Apache" appear
in their name, without
 *    prior written permission of the Apache Software Foundation.
*
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 *
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH
DAMAGE.
 * ====================================================================
 *
 * This
software consists of voluntary contributions made by many
 * individuals on behalf of the
Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please
see
 * <http://www.apache.org/>.
 */
package org.apache.commons.codec;
   
  -/**
 * Encodes a string into a soundex value.  Sounde is an encoding used to
 * relate
similar names, but can also be used as a general purpose
 * scheme to find word with similar
phonemes. 
 * More information may be found at: http://www.bluepoof.com/Soundex/info2.html
* 
 * @todo Needs internationalisation in a future release.
 *
 * @author tobrien@transolutions.net
* @version $Revision$ $Date$
 */
public class RefinedSoundex implements Encoder {

    static
public final char[] US_ENGLISH_MAPPING =
        "01360240043788015936020505".toCharArray();

   static public final RefinedSoundex US_ENGLISH = new RefinedSoundex();
    
    private
char[] soundexMapping;

    public RefinedSoundex() {
        this(US_ENGLISH_MAPPING);
 
  }

    public RefinedSoundex(char[] mapping) {
        this.soundexMapping = mapping;
 
  }

    /**
     * Get the SoundEx value of a string.
     * This implementation is taken
from the code-snippers on 
     * http://www.sourceforge.net/
     */
    public String soundex(String
str) {
       
        StringBuffer sBuf = new StringBuffer();        
        str = str.toUpperCase();

       sBuf.append( str.charAt(0) );

        char last, mapped, current;
        last = '*';

       for( int i = 0; i < str.length(); i++ ) {

            current = getMappingCode(
str.charAt(i) );
            if( current == last ) {
                continue;
          
 } else if( current != 0 ) {
                sBuf.append( current );   
            }
   
        
            last = current;             
            
        }
        
       
return sBuf.toString();
    }

    public String encode(String pString) {
        return(
soundex( pString ) );   
    }

    /**
     * Used internally by the SoundEx algorithm.
    */
    private char getMappingCode(char c) {
        if( !Character.isLetter(c) ) {
 
          return 0;
        } else {
            return soundexMapping[Character.toUpperCase(c)
- 'A'];
        }
    }
}
  \ No newline at end of file
  +/**
 * Encodes a string into a soundex value.  Sounde is an encoding used to
 * relate
similar names, but can also be used as a general purpose
 * scheme to find word with similar
phonemes. 
 * More information may be found at: http://www.bluepoof.com/Soundex/info2.html
* 
 * @todo Needs internationalisation in a future release.
 *
 * @author tobrien@transolutions.net
* @version $Revision$ $Date$
 */
public class RefinedSoundex implements Encoder {

    static
public final char[] US_ENGLISH_MAPPING =
        "01360240043788015936020505".toCharArray();

   static public final RefinedSoundex US_ENGLISH = new RefinedSoundex();
    
    private
char[] soundexMapping;

    public RefinedSoundex() {
        this(US_ENGLISH_MAPPING);
 
  }

    public RefinedSoundex(char[] mapping) {
        this.soundexMapping = mapping;
 
  }

    /**
     * Get the SoundEx value of a string.
     * This implementation is taken
from the code-snippers on 
     * http://www.sourceforge.net/
     */
    public String soundex(String
str) {
        if(null == str || str.length() == 0) { return str; }
       
        StringBuffer
sBuf = new StringBuffer();        
        str = str.toUpperCase();

        sBuf.append(
str.charAt(0) );

        char last, mapped, current;
        last = '*';

        for( int
i = 0; i < str.length(); i++ ) {

            current = getMappingCode( str.charAt(i) );
           if( current == last ) {
                continue;
            } else if( current
!= 0 ) {
                sBuf.append( current );   
            }
            
          
 last = current;             
            
        }
        
        return sBuf.toString();
   }

    public String encode(String pString) {
        return( soundex( pString ) );   
   }

    /**
     * Used internally by the SoundEx algorithm.
     */
    private char getMappingCode(char
c) {
        if( !Character.isLetter(c) ) {
            return 0;
        } else {
      
     return soundexMapping[Character.toUpperCase(c) - 'A'];
        }
    }
}
  \ No newline at end of file
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/codec/src/java/org/apache/commons/codec/Soundex.java
  
  Index: Soundex.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec/src/java/org/apache/commons/codec/Soundex.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Soundex.java	18 Nov 2002 12:41:24 -0000	1.3
  +++ Soundex.java	18 Nov 2002 13:00:26 -0000	1.4
  @@ -1,4 +1,4 @@
   /* ====================================================================
 * The Apache Software
License, Version 1.1
 *
 * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
* reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification,
are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions
of source code must retain the above copyright
 *    notice, this list of conditions and the
following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in
 *    the documentation
and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation
included with the redistribution,
 *    if any, must include the following acknowledgment:
*       "This product includes software developed by the
 *        Apache Software Foundation
(http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software
itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The
names "Apache" and "Apache Software Foundation" and
 *    "Apache Commons" must not be used
to endorse or promote products
 *    derived from this software without prior written permission.
For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived
from this software may not be called "Apache",
 *    "Apache Turbine", nor may "Apache" appear
in their name, without
 *    prior written permission of the Apache Software Foundation.
*
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 *
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH
DAMAGE.
 * ====================================================================
 *
 * This
software consists of voluntary contributions made by many
 * individuals on behalf of the
Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please
see
 * <http://www.apache.org/>.
 */
package org.apache.commons.codec;
   /**
 * Encodes a string into a refined soundex value.  
 * A refined soundex code is optimized
for spell checking word. 
 * "Soundex" method originally developed by Margaret Odell and 
*          Robert Russell
 * 
 * http://www.bluepoof.com/Soundex/info2.html
 * 
 * @todo Needs
internationalisation in a future release.
 *
 * @author bayard@generationjava.com
 * @author
tobrien@transolutions.net
 * @version $Revision$ $Date$
 */
public class Soundex implements
Encoder {

    static public final char[] US_ENGLISH_MAPPING =
        "01230120022455012623010202".toCharArray();

   static public final Soundex US_ENGLISH = new Soundex();
    
    private char[] soundexMapping;
   private int maxLength = 4;

      public Soundex() {
        this(US_ENGLISH_MAPPING);
    }
  -    public Soundex(char[] mapping) {
        this.soundexMapping = mapping;
    }

   
/**
     * Get the SoundEx value of a string.
     * This implementation is taken from the
code-snippers on 
     * http://www.sourceforge.net/
     */
    public String soundex(String
str) {
        char out[] = { '0', '0', '0', '0' };
        char last, mapped;
        int
incount = 1, count = 1;
        out[0] = Character.toUpperCase( str.charAt(0) );
        last
= getMappingCode( str.charAt(0) );
        while( (incount < str.length() ) &&

               (mapped = getMappingCode(str.charAt(incount++))) != 0 &&
        
      (count < maxLength) )
        {
            if( (mapped != '0') && (mapped
!= last) ) {
                out[count++] = mapped;
            }
            last = mapped;
       }
        return new String(out);
    }

    public String encode(String pString) {
       return( soundex( pString ) );   
    }

    /**
     * Used internally by the SoundEx
algorithm.
     */
    private char getMappingCode(char c) {
        if( !Character.isLetter(c)
) {
            return 0;
        } else {
            return soundexMapping[Character.toUpperCase(c)
- 'A'];
        }
    }

	/**
	 * Returns the maxLength.  Standard Soundex
	 * @return int
 */
	public int getMaxLength() {
		return maxLength;
	}

	/**
	 * Sets the maxLength.
	 *
@param maxLength The maxLength to set
	 */
	public void setMaxLength(int maxLength) {
		this.maxLength
= maxLength;
	}

}
  \ No newline at end of file
  +    public Soundex(char[] mapping) {
        this.soundexMapping = mapping;
    }

   
/**
     * Get the SoundEx value of a string.
     * This implementation is taken from the
code-snippers on 
     * http://www.sourceforge.net/
     */
    public String soundex(String
str) {
        if(null == str || str.length() == 0) { return str; }
        
        char
out[] = { '0', '0', '0', '0' };
        char last, mapped;
        int incount = 1, count
= 1;
        out[0] = Character.toUpperCase( str.charAt(0) );
        last = getMappingCode(
str.charAt(0) );
        while( (incount < str.length() ) && 
               (mapped
= getMappingCode(str.charAt(incount++))) != 0 &&
               (count < maxLength)
)
        {
            if( (mapped != '0') && (mapped != last) ) {
             
  out[count++] = mapped;
            }
            last = mapped;
        }
        return
new String(out);
    }

    public String encode(String pString) {
        return( soundex(
pString ) );   
    }

    /**
     * Used internally by the SoundEx algorithm.
     */
 
  private char getMappingCode(char c) {
        if( !Character.isLetter(c) ) {
          
 return 0;
        } else {
            return soundexMapping[Character.toUpperCase(c) - 'A'];
       }
    }

	/**
	 * Returns the maxLength.  Standard Soundex
	 * @return int
	 */
	public
int getMaxLength() {
		return maxLength;
	}

	/**
	 * Sets the maxLength.
	 * @param maxLength
The maxLength to set
	 */
	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
}

}
  \ No newline at end of file
  
  
  
  1.2       +6 -4      jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestAll.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAll.java	18 Nov 2002 12:41:24 -0000	1.1
  +++ TestAll.java	18 Nov 2002 13:00:26 -0000	1.2
  @@ -79,6 +79,8 @@
           TestSuite suite = new TestSuite();
           suite.addTest(org.apache.commons.codec.base64.TestAll.suite());
           suite.addTest(TestMetaphone.suite());
  +        suite.addTest(TestSoundex.suite());
  +        suite.addTest(TestRefinedSoundex.suite());
           return suite;
       }
           
  
  
  
  1.2       +9 -7      jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestMetaphone.java
  
  Index: TestMetaphone.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestMetaphone.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestMetaphone.java	18 Nov 2002 12:41:24 -0000	1.1
  +++ TestMetaphone.java	18 Nov 2002 13:00:26 -0000	1.2
  @@ -63,14 +63,12 @@
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  -import java.util.Arrays;
  -import java.util.Random;
   
   /**
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
    */
  -public class TestMetaphone extends TestCase {
  +public class TestMetaphone extends TestEncoder {
   
       public TestMetaphone(String name) {
           super(name);
  @@ -90,6 +88,10 @@
           _metaphone = null;
       }
   
  +    protected Encoder makeEncoder() {
  +        return new Metaphone();
  +    }
  +    
       // ------------------------------------------------------------------------
   
       public void testMetaphone() {
  
  
  
  1.1                  jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestEncoder.java
  
  Index: TestEncoder.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestEncoder.java,v
1.1 2002/11/18 13:00:26 rwaldhoff Exp $
   * $Revision: 1.1 $
   * $Date: 2002/11/18 13:00:26 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.codec;
  
  import junit.framework.TestCase;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2002/11/18 13:00:26 $
   * @author Rodney Waldhoff
   */
  public abstract class TestEncoder extends TestCase {
  
      public TestEncoder(String name) {
          super(name);
      }
  
      protected abstract Encoder makeEncoder();
  
      // ------------------------------------------------------------------------
  
      public void testEncodeEmpty() {
          Encoder encoder = makeEncoder();
          encoder.encode("");
          encoder.encode(" ");
          encoder.encode("\t");
      }        
  
      public void testEncodeNull() {
          Encoder encoder = makeEncoder();
          encoder.encode(null);
      }        
  }
  
  
  
  1.1                  jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestRefinedSoundex.java
  
  Index: TestRefinedSoundex.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestRefinedSoundex.java,v
1.1 2002/11/18 13:00:26 rwaldhoff Exp $
   * $Revision: 1.1 $
   * $Date: 2002/11/18 13:00:26 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.codec;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2002/11/18 13:00:26 $
   * @author Rodney Waldhoff
   */
  public class TestRefinedSoundex extends TestEncoder {
  
      public TestRefinedSoundex(String name) {
          super(name);
      }
  
      public static Test suite() {
          return (new TestSuite(TestRefinedSoundex.class));
      }
  
      public void setUp() throws Exception {        
          super.setUp();
          _encoder = new RefinedSoundex();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
          _encoder = null;
      }
  
      protected Encoder makeEncoder() {
          return new RefinedSoundex();
      }
  
      // ------------------------------------------------------------------------
  
      public void testEncode() {
          assertEquals("T6036084",_encoder.encode("testing"));
          assertEquals("T60",_encoder.encode("The"));
          assertEquals("Q503",_encoder.encode("quick"));
          assertEquals("B1908",_encoder.encode("brown"));
          assertEquals("F205",_encoder.encode("fox"));
          assertEquals("J408106",_encoder.encode("jumped"));
          assertEquals("O0209",_encoder.encode("over"));
          assertEquals("T60",_encoder.encode("the"));
          assertEquals("L7050",_encoder.encode("lazy"));
          assertEquals("D6043",_encoder.encode("dogs"));
      }
  
      private RefinedSoundex _encoder = null;
  }
  
  
  
  1.1                  jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestSoundex.java
  
  Index: TestSoundex.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/codec/src/test/org/apache/commons/codec/TestSoundex.java,v
1.1 2002/11/18 13:00:26 rwaldhoff Exp $
   * $Revision: 1.1 $
   * $Date: 2002/11/18 13:00:26 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.codec;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2002/11/18 13:00:26 $
   * @author Rodney Waldhoff
   */
  public class TestSoundex extends TestEncoder {
  
      public TestSoundex(String name) {
          super(name);
      }
  
      public static Test suite() {
          return (new TestSuite(TestSoundex.class));
      }
  
      public void setUp() throws Exception {        
          super.setUp();
          _encoder = new Soundex();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
          _encoder = null;
      }
  
      protected Encoder makeEncoder() {
          return new Soundex();
      }
  
      // ------------------------------------------------------------------------
  
      public void testEncode() {
          assertEquals("T235",_encoder.encode("testing"));
          assertEquals("T000",_encoder.encode("The"));
          assertEquals("Q200",_encoder.encode("quick"));
          assertEquals("B650",_encoder.encode("brown"));
          assertEquals("F200",_encoder.encode("fox"));
          assertEquals("J513",_encoder.encode("jumped"));
          assertEquals("O160",_encoder.encode("over"));
          assertEquals("T000",_encoder.encode("the"));
          assertEquals("L200",_encoder.encode("lazy"));
          assertEquals("D200",_encoder.encode("dogs"));
      }
  
      private Soundex _encoder = null;
  }
  
  
  

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


Mime
View raw message