Author: elecharny
Date: Thu Jul  5 10:38:06 2012
New Revision: 1357542

URL: http://svn.apache.org/viewvc?rev=1357542&view=rev
Log:
Added a test for the Page.findPos() method

Modified:
    
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java

Modified: 
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java?rev=1357542&r1=1357541&r2=1357542&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java 
(original)
+++ 
labs/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/btree/LeafTest.java 
Thu Jul  5 10:38:06 2012
@@ -361,4 +361,35 @@ public class LeafTest
         assertEquals( Long.valueOf( 6L ), newLeaf.keys[5] );
         assertEquals( Long.valueOf( 8L ), newLeaf.keys[6] );
     }
+    
+    
+    /**
+     * Test the findPos() method
+     * @throws Exception
+     */
+    @Test
+    public void testFindPos() throws Exception
+    {
+        Leaf<Long, String> leaf = new Leaf<Long, String>( btree );
+        
+        // Inject the values
+        for ( long i = 0; i < 8; i++ )
+        {
+            long value = i + i + 1;
+            leaf = (Leaf<Long, String>)((ModifyResult<Long, 
String>)leaf.insert( 0L, value, "V" + value )).getModifiedPage();
+        }
+        
+        // Check the findPos() method now
+        for ( long i = 0; i < 17; i++ )
+        {
+            if ( i % 2 == 1 )
+            {
+                assertEquals( - ( i/2 + 1 ), leaf.findPos( i ) );
+            }
+            else
+            {
+                assertEquals( i/2, leaf.findPos( i ) );
+            }
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to