diff --git a/src/test/org/apache/commons/collections/TestCollectionUtils.java b/src/test/org/apache/commons/collections/TestCollectionUtils.java index 7fbb60663..72018fa35 100644 --- a/src/test/org/apache/commons/collections/TestCollectionUtils.java +++ b/src/test/org/apache/commons/collections/TestCollectionUtils.java @@ -1,7 +1,7 @@ /* - * $Id: TestCollectionUtils.java,v 1.8 2002/11/24 16:23:21 scolebourne Exp $ - * $Revision: 1.8 $ - * $Date: 2002/11/24 16:23:21 $ + * $Id: TestCollectionUtils.java,v 1.9 2002/11/24 21:12:30 scolebourne Exp $ + * $Revision: 1.9 $ + * $Date: 2002/11/24 21:12:30 $ * * ==================================================================== * @@ -66,7 +66,7 @@ import java.util.*; /** * @author Rodney Waldhoff - * @version $Revision: 1.8 $ $Date: 2002/11/24 16:23:21 $ + * @version $Revision: 1.9 $ $Date: 2002/11/24 21:12:30 $ */ public class TestCollectionUtils extends TestCase { public TestCollectionUtils(String testName) { @@ -431,6 +431,40 @@ public class TestCollectionUtils extends TestCase { assertEquals("Two", list.get(0)); } + public void testSelect() { + List list = new ArrayList(); + list.add("One"); + list.add("Two"); + list.add("Three"); + list.add("Four"); + Collection output = CollectionUtils.select(list, new Predicate() { + public boolean evaluate(Object input) { + return (input.equals("Two")); + } + }); + assertEquals(4, list.size()); + assertEquals(1, output.size()); + assertEquals("Two", output.iterator().next()); + } + + public void testSelectRejected() { + List list = new ArrayList(); + list.add("One"); + list.add("Two"); + list.add("Three"); + list.add("Four"); + Collection output = CollectionUtils.selectRejected(list, new Predicate() { + public boolean evaluate(Object input) { + return (input.equals("Two")); + } + }); + assertEquals(4, list.size()); + assertEquals(3, output.size()); + assertTrue(output.contains("One")); + assertTrue(output.contains("Three")); + assertTrue(output.contains("Four")); + } + public void testTransform1() { List list = new ArrayList(); list.add("1");