Test the new countMatches method

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2002-12-08 15:29:26 +00:00
parent 0ac46dd1c3
commit 92d67a604d
1 changed files with 19 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/* /*
* $Id: TestCollectionUtils.java,v 1.9 2002/11/24 21:12:30 scolebourne Exp $ * $Id: TestCollectionUtils.java,v 1.10 2002/12/08 15:29:26 scolebourne Exp $
* $Revision: 1.9 $ * $Revision: 1.10 $
* $Date: 2002/11/24 21:12:30 $ * $Date: 2002/12/08 15:29:26 $
* *
* ==================================================================== * ====================================================================
* *
@ -66,7 +66,7 @@ import java.util.*;
/** /**
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Revision: 1.9 $ $Date: 2002/11/24 21:12:30 $ * @version $Revision: 1.10 $ $Date: 2002/12/08 15:29:26 $
*/ */
public class TestCollectionUtils extends TestCase { public class TestCollectionUtils extends TestCase {
public TestCollectionUtils(String testName) { public TestCollectionUtils(String testName) {
@ -431,6 +431,21 @@ public class TestCollectionUtils extends TestCase {
assertEquals("Two", list.get(0)); assertEquals("Two", list.get(0));
} }
public void testCountMatches() {
List list = new ArrayList();
list.add("One");
list.add("Two");
list.add("Three");
list.add("Four");
int count = CollectionUtils.countMatches(list, new Predicate() {
public boolean evaluate(Object input) {
return (input.equals("Two"));
}
});
assertEquals(4, list.size());
assertEquals(1, count);
}
public void testSelect() { public void testSelect() {
List list = new ArrayList(); List list = new ArrayList();
list.add("One"); list.add("One");