Add tests for select/selectRejected methods
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aa139cebf0
commit
0ac46dd1c3
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Id: TestCollectionUtils.java,v 1.8 2002/11/24 16:23:21 scolebourne Exp $
|
* $Id: TestCollectionUtils.java,v 1.9 2002/11/24 21:12:30 scolebourne Exp $
|
||||||
* $Revision: 1.8 $
|
* $Revision: 1.9 $
|
||||||
* $Date: 2002/11/24 16:23:21 $
|
* $Date: 2002/11/24 21:12:30 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -66,7 +66,7 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rodney Waldhoff
|
* @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 class TestCollectionUtils extends TestCase {
|
||||||
public TestCollectionUtils(String testName) {
|
public TestCollectionUtils(String testName) {
|
||||||
|
@ -431,6 +431,40 @@ public class TestCollectionUtils extends TestCase {
|
||||||
assertEquals("Two", list.get(0));
|
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() {
|
public void testTransform1() {
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
list.add("1");
|
list.add("1");
|
||||||
|
|
Loading…
Reference in New Issue