commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marcospera...@apache.org
Subject svn commit: r1360149 - /commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java
Date Wed, 11 Jul 2012 12:35:51 GMT
Author: marcosperanza
Date: Wed Jul 11 12:35:51 2012
New Revision: 1360149

URL: http://svn.apache.org/viewvc?rev=1360149&view=rev
Log:
Added new tests case

Modified:
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java?rev=1360149&r1=1360148&r2=1360149&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java
(original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java
Wed Jul 11 12:35:51 2012
@@ -21,11 +21,13 @@ package org.apache.commons.graph.collect
 
 import static java.util.Collections.sort;
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 
 import java.util.ArrayList;
-
+import java.util.Collection;
 import java.util.List;
+import java.util.NoSuchElementException;
 import java.util.Queue;
 import java.util.Random;
 
@@ -58,6 +60,7 @@ public final class FibonacciHeapTestCase
     public void emptyWhenCreated()
     {
         assertThat( queue.isEmpty(), is( true ) );
+        assertThat( queue.poll(), nullValue() );
     }
 
     @Test
@@ -138,6 +141,63 @@ public final class FibonacciHeapTestCase
             Integer i = queue.poll();
             assertThat( i, is( integer ) );
         }
+        
+        assertThat( queue.isEmpty(), is( true ) );
+    }
+
+    @Test
+    public void addAllAndContinsItem()
+    {
+        Collection<Integer> c = new ArrayList<Integer>();
+        
+        c.add( 50 );
+        c.add( 100 );
+        c.add( 20 );
+        c.add( 21 );
+
+        queue.addAll( c );
+            
+        assertThat( queue.isEmpty(), is( false ) );
+        assertThat( queue.containsAll( c ), is( true ) );
+        
+        assertThat( queue.contains( 100 ), is( true ) );
+        assertThat( queue.contains( 21 ), is( true ) );
+        assertThat( queue.contains( 50 ), is( true ) );
+        assertThat( queue.contains( 20 ), is( true ) );
     }
 
+    @Test
+    public void clearQueue()
+    {
+        final Random r = new Random( System.currentTimeMillis() );
+        for ( int i = 0; i < 1000; i++ )
+        {
+            Integer number = new Integer( r.nextInt( 10000 ) );
+            queue.add( number );
+        }
+
+        assertThat( queue.isEmpty(), is( false ) );
+        queue.clear();
+        assertThat( queue.isEmpty(), is( true ) );
+    }
+
+    @Test
+    public void offerPeekAndElement()
+    {
+        queue.offer( 50 );
+        queue.offer( 100 );
+        queue.offer( 20 );
+        queue.offer( 21 );
+
+        assertThat( queue.isEmpty(), is( false ) );
+        assertThat( queue.peek(), is( 20 ) );
+        assertThat( queue.element(), is( 20 ) );
+        assertThat( queue.size(), is( 4 ) );
+    }
+    
+    @Test( expected = NoSuchElementException.class )
+    public void elementThrowsException()
+    {
+        assertThat( queue.element(), is( 20 ) );
+    }
 }



Mime
View raw message