1 package uk.co.jezuk.mango; 2 3 import junit.framework.*; 4 5 import java.util.Collection ; 6 import java.util.ArrayList ; 7 8 public class RemoveIfTest extends TestCase 9 { 10 java.util.List list; 11 12 public RemoveIfTest(String name) { super(name); } 13 public static Test suite() { return new TestSuite(RemoveIfTest.class); } 14 15 protected void setUp() 16 { 17 list = new java.util.ArrayList (); 18 for(int i = 0; i < 10; ++i) 19 list.add(new Integer (i)); 20 } 22 public void test1() 23 { 24 Algorithms.removeIf(list, Bind.First(Predicates.LessThanEquals(), new Integer (7))); 25 26 assertEquals(7, list.size()); 27 assertEquals(null, Algorithms.find(list, new Integer (7))); 28 assertEquals(null, Algorithms.find(list, new Integer (8))); 29 assertEquals(null, Algorithms.find(list, new Integer (9))); 30 } 32 public void test2() 33 { 34 Algorithms.removeIf(list, 1, 5, Bind.First(Predicates.LessThanEquals(), new Integer (7))); 35 36 assertEquals(10, list.size()); 37 assertEquals(list.get(7), Algorithms.find(list, new Integer (7))); 38 } 40 } | Popular Tags |