directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r492181 - /directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizerTest.java
Date Wed, 03 Jan 2007 15:32:22 GMT
Author: elecharny
Date: Wed Jan  3 07:32:21 2007
New Revision: 492181

URL: http://svn.apache.org/viewvc?view=rev&rev=492181
Log:
Fixed the tests accordingly to the Space handling modification in PrepareString

Modified:
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizerTest.java

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizerTest.java?view=diff&rev=492181&r1=492180&r2=492181
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizerTest.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizerTest.java
Wed Jan  3 07:32:21 2007
@@ -23,6 +23,8 @@
 
 import junit.framework.TestCase;
 
+//import org.apache.directory.shared.ldap.util.StringTools;
+
 /**
  *
  * Test the normalizer class
@@ -34,56 +36,56 @@
    public void testDeepTrimNormalizerNull() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( "  ", normalizer.normalize( (String)null ) );
+       assertEquals( "", normalizer.normalize( (String)null ) );
    }
 
    public void testDeepTrimNormalizerEmpty() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( "  ", normalizer.normalize( "" ) );
+       assertEquals( "", normalizer.normalize( "" ) );
    }
 
    public void testDeepTrimNormalizerOneSpace() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( "  ", normalizer.normalize( " " ) );
+       assertEquals( "", normalizer.normalize( " " ) );
    }
 
    public void testDeepTrimNormalizerTwoSpaces() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( "  ", normalizer.normalize( "  " ) );
+       assertEquals( "", normalizer.normalize( "  " ) );
    }
 
    public void testDeepTrimNormalizerNSpaces() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( "  ", normalizer.normalize( "      " ) );
+       assertEquals( "", normalizer.normalize( "      " ) );
    }
 
    public void testInsignifiantSpacesStringOneChar() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( " a ", normalizer.normalize( "a" ) );
+       assertEquals( "a", normalizer.normalize( "a" ) );
    }
 
    public void testInsignifiantSpacesStringTwoChars() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( " aa ", normalizer.normalize( "aa" ) );
+       assertEquals( "aa", normalizer.normalize( "aa" ) );
    }
 
    public void testInsignifiantSpacesStringNChars() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( " aaaaa ", normalizer.normalize( "aaaaa" ) );
+       assertEquals( "aaaaa", normalizer.normalize( "aaaaa" ) );
    }
 
    public void testInsignifiantSpacesStringOneCombining() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
        char[] chars = new char[]{ ' ', 0x0310 };
-       char[] expected = new char[]{ ' ', ' ', 0x0310, ' ' };
+       char[] expected = new char[]{ ' ', 0x0310 };
        assertEquals( new String( expected ), normalizer.normalize( new String( chars ) )
);
    }
 
@@ -91,36 +93,36 @@
    {
        Normalizer normalizer = new DeepTrimNormalizer();
        char[] chars = new char[]{ ' ', 0x0310, ' ', 0x0311, ' ', 0x0312 };
-       char[] expected = new char[]{ ' ', ' ', 0x0310, ' ', 0x0311, ' ', 0x0312, ' ' };
+       char[] expected = new char[]{ ' ', 0x0310, ' ', 0x0311, ' ', 0x0312 };
        assertEquals( new String( expected ), normalizer.normalize( new String( chars ) )
);
    }
 
    public void testInsignifiantSpacesStringCharsSpaces() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( " a ", normalizer.normalize( " a" ) );
-       assertEquals( " a ", normalizer.normalize( "a " ) );
-       assertEquals( " a ", normalizer.normalize( " a " ) );
-       assertEquals( " a a ", normalizer.normalize( "a a" ) );
-       assertEquals( " a a ", normalizer.normalize( " a a" ) );
-       assertEquals( " a a ", normalizer.normalize( "a a " ) );
-       assertEquals( " a a ", normalizer.normalize( "a  a" ) );
-       assertEquals( " a a ", normalizer.normalize( " a   a " ) );
-       assertEquals( " aaa aaa aaa ", normalizer.normalize( "  aaa   aaa   aaa  " ) );
+       assertEquals( "a", normalizer.normalize( " a" ) );
+       assertEquals( "a", normalizer.normalize( "a " ) );
+       assertEquals( "a", normalizer.normalize( " a " ) );
+       assertEquals( "a a", normalizer.normalize( "a a" ) );
+       assertEquals( "a a", normalizer.normalize( " a a" ) );
+       assertEquals( "a a", normalizer.normalize( "a a " ) );
+       assertEquals( "a a", normalizer.normalize( "a  a" ) );
+       assertEquals( "a a", normalizer.normalize( " a   a " ) );
+       assertEquals( "aaa aaa aaa", normalizer.normalize( "  aaa   aaa   aaa  " ) );
    }
 
    public void testNormalizeCharsCombiningSpaces() throws NamingException
    {
        Normalizer normalizer = new DeepTrimNormalizer();
        char[] chars = new char[]{ ' ', 0x0310, 'a', 'a', ' ', ' ',  0x0311, ' ', ' ', 'a',
0x0311, 0x0312 };
-       char[] expected = new char[]{ ' ', ' ', 0x0310, 'a', 'a', ' ', ' ',  0x0311, ' ',
'a', 0x0311, 0x0312, ' ' };
+       char[] expected = new char[]{ ' ', 0x0310, 'a', 'a', ' ', ' ',  0x0311, ' ', 'a',
0x0311, 0x0312 };
        assertEquals( new String( expected ), normalizer.normalize( new String( chars ) )
);
    }
 
    public void testNormalizeString() throws Exception
    {
        Normalizer normalizer = new DeepTrimNormalizer();
-       assertEquals( " abcd ", normalizer.normalize( "abcd" ) );
+       assertEquals( "abcd", normalizer.normalize( "abcd" ) );
    }
 
    public void testMapToSpace() throws Exception
@@ -129,7 +131,7 @@
        char[] chars = new char[]{ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0085, 0x00A0, 0x1680,
            0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009,
0x200A,
            0x2028, 0x2029, 0x202F, 0x205F };
-       assertEquals( "  ", normalizer.normalize( new String( chars ) ) );
+       assertEquals( "", normalizer.normalize( new String( chars ) ) );
    }
 
    public void testNormalizeIgnore() throws Exception
@@ -161,10 +163,10 @@
 
        chars[pos++] = 0x00AD;
 
-       assertEquals( "  ", normalizer.normalize( new String( chars ) ) );
+       assertEquals( "", normalizer.normalize( new String( chars ) ) );
    }
 
-	/*
+   /*
    public void testSpeed() throws Exception
    {
        Normalizer normalizer = new DeepTrimNormalizer();
@@ -172,22 +174,37 @@
            0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009,
0x200A,
            0x2028, 0x2029, 0x202F, 0x205F };
        String s = new String( chars );
-       assertEquals( "  ", normalizer.normalize( s ) );
+       assertEquals( "", normalizer.normalize( s ) );
        
-       String t = "xs crvtbynujikl7897790";
+       String t = "xs crvtbynU  Jikl7897790";
        
        Normalizer normalizer2 = new DeepTrimToLowerNormalizer();
+       
+       String s1 = (String)normalizer2.normalize( t );
 
        long t0 = System.currentTimeMillis();
 
-       for ( int i = 0; i < 1000000; i++ )
+       for ( int i = 0; i < 100000; i++ )
        {
-           normalizer.normalize( t );
+           normalizer2.normalize( t );
        }
        
        long t1 = System.currentTimeMillis();
        
        System.out.println( t1 - t0 );
+
+       String s2 = StringTools.deepTrimToLower( t );
+
+       t0 = System.currentTimeMillis();
+
+       for ( int i = 0; i < 100000; i++ )
+       {
+           StringTools.deepTrimToLower( t );
+       }
+       
+       t1 = System.currentTimeMillis();
+       
+       System.out.println( t1 - t0 );
    }
-	*/
+   */
 }



Mime
View raw message