directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r633716 - in /directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src: main/java/org/apache/directory/server/core/avltree/AvlTree.java test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Date Tue, 04 Mar 2008 23:58:35 GMT
Author: akarasulu
Date: Tue Mar  4 15:58:23 2008
New Revision: 633716

URL: http://svn.apache.org/viewvc?rev=633716&view=rev
Log:
fix small bug with setting of the last reference

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java?rev=633716&r1=633715&r2=633716&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
Tue Mar  4 15:58:23 2008
@@ -75,6 +75,7 @@
 	    {
 	      root = new LinkedAvlNode<K>( key );
 	      first = root;
+	      last = root;
 	      return;
 	    }
 	    

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java?rev=633716&r1=633715&r2=633716&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Tue Mar  4 15:58:23 2008
@@ -59,10 +59,13 @@
           });  
     }
     
+    
     @Test
     public void testEmpty()
     {
       assertTrue( tree.isEmpty() );
+      assertNull( tree.getFirst() );
+      assertNull( tree.getLast() );
       
       tree.remove( 97 ); // remove a non-existing key
       assertTrue( tree.isEmpty() );
@@ -71,6 +74,32 @@
     }
     
     
+    @Test 
+    public void testFirstAndLast()
+    {
+        tree.insert( 7 );
+        assertFalse( tree.isEmpty() );
+        assertNotNull( tree.getFirst() );
+        assertNotNull( tree.getLast() );
+        
+        tree.insert( 10 );
+        assertEquals( 2, tree.getSize() );
+        assertNotNull( tree.getFirst() );
+        assertNotNull( tree.getLast() );
+        assertFalse( tree.getFirst().equals( tree.getLast() ) );
+        assertTrue( tree.getFirst().getKey().equals( 7 ) );
+        assertTrue( tree.getLast().getKey().equals( 10 ) );
+        
+        tree.insert( 3 );
+        assertTrue( tree.getFirst().getKey().equals( 3 ) );
+        assertTrue( tree.getLast().getKey().equals( 10 ) );
+        
+        tree.insert( 11 );
+        assertTrue( tree.getFirst().getKey().equals( 3 ) );
+        assertTrue( tree.getLast().getKey().equals( 11 ) );
+    }
+    
+    
     @Test
     public void testInsert()
     {
@@ -81,8 +110,8 @@
         assertTrue( 1 == tree.getSize() );
 
         assertNotNull( tree.getFirst() );
-        assertNull( tree.getLast() );
-        assertNotSame( tree.getFirst(), tree.getLast() );
+        assertNotNull( tree.getLast() );
+        assertTrue( tree.getFirst() == tree.getLast() );
         
         tree.remove( 3 );
         



Mime
View raw message