commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestCollectionUtils.java
Date Sun, 24 Nov 2002 21:12:30 GMT
scolebourne    2002/11/24 13:12:30

  Modified:    collections/src/test/org/apache/commons/collections
                        TestCollectionUtils.java
  Log:
  Add tests for select/selectRejected methods
  
  Revision  Changes    Path
  1.9       +38 -4     jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java
  
  Index: TestCollectionUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestCollectionUtils.java	24 Nov 2002 16:23:21 -0000	1.8
  +++ TestCollectionUtils.java	24 Nov 2002 21:12:30 -0000	1.9
  @@ -431,6 +431,40 @@
           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");
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message