commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1076463 - /commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java
Date Thu, 03 Mar 2011 00:02:11 GMT
Author: mbenson
Date: Thu Mar  3 00:02:10 2011
New Revision: 1076463

URL: http://svn.apache.org/viewvc?rev=1076463&view=rev
Log:
additional tests

Modified:
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java?rev=1076463&r1=1076462&r2=1076463&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java
Thu Mar  3 00:02:10 2011
@@ -30,6 +30,7 @@ import junit.framework.TestSuite;
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.core.Constant;
+import org.apache.commons.functor.core.IsEqual;
 
 /**
  * @version $Revision$ $Date$
@@ -221,9 +222,14 @@ public class TestFilteredIterable extend
         for (String s : strings) {
             assertTrue(s instanceof String);
         }
+    }
+
+    public void testRetainOneType2() {
+        Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L,
BigInteger.ZERO);
         Iterator<Number> iterator = FilteredIterable.of(objects).retain(Number.class).iterator();
         assertEquals(2L, iterator.next());
         assertEquals(BigInteger.ZERO, iterator.next());
+        assertFalse(iterator.hasNext());
     }
 
     public void testRetainMultipleTypes() {
@@ -231,6 +237,22 @@ public class TestFilteredIterable extend
         Iterator<Object> iterator = FilteredIterable.of(objects).retain(Long.class,
BigInteger.class).iterator();
         assertEquals(2L, iterator.next());
         assertEquals(BigInteger.ZERO, iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testMultipleLevels() {
+        Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L,
BigInteger.ZERO);
+        Iterator<String> iterator = FilteredIterable.of(objects).retain(String.class).retain(IsEqual.to("foo"))
+                .iterator();
+        assertEquals("foo", iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testMultipleLevels2() {
+        Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L,
BigInteger.ZERO);
+        Iterator<Long> iterator = FilteredIterable.of(objects).retain(Number.class).retain(Long.class).iterator();
+        assertEquals(2L, iterator.next().longValue());
+        assertFalse(iterator.hasNext());
     }
 
     public void testRetainNullType() {



Mime
View raw message