1 package uk.co.jezuk.mango; 2 3 import junit.framework.*; 4 5 public class FindPositionIfTest extends TestCase 6 { 7 java.util.List list; 8 9 public FindPositionIfTest(String name) { super(name); } 10 public static Test suite() { return new TestSuite(FindPositionIfTest.class); } 11 12 protected void setUp() 13 { 14 list = new java.util.ArrayList (); 15 for(int i = 0; i < 10; ++i) 16 list.add(new Integer (i)); 17 } 19 public void test1() 20 { 21 assertEquals(2, Algorithms.findPositionIf(list, 22 Bind.First(Predicates.EqualTo(), new Integer (2)) 23 )); 24 } 25 26 public void test2() 27 { 28 assertEquals(4, Algorithms.findPositionIf(list, 29 Bind.First(Predicates.EqualTo(), new Integer (4)) 30 )); 31 } 32 33 public void test3() 34 { 35 assertEquals(7, Algorithms.findPositionIf(list, 36 Bind.First(Predicates.EqualTo(), new Integer (7)) 37 )); 38 } 39 40 public void test4() 41 { 42 assertEquals(-1, Algorithms.findPositionIf(list, 43 Bind.First(Predicates.EqualTo(), new Integer (99)) 44 )); 45 } 46 47 public void test5() 48 { 49 assertEquals(-1, Algorithms.findPositionIf(list, 50 Bind.First(Predicates.EqualTo(), new String ("charles dickens")) 51 )); 52 } } | Popular Tags |