KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > co > jezuk > mango > FindPositionIfTest


1 package uk.co.jezuk.mango;
2
3 import junit.framework.*;
4
5 public class FindPositionIfTest extends TestCase
6 {
7   java.util.List JavaDoc list;
8
9   public FindPositionIfTest(String JavaDoc 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 JavaDoc();
15     for(int i = 0; i < 10; ++i)
16       list.add(new Integer JavaDoc(i));
17   } // setUp
18

19   public void test1()
20   {
21     assertEquals(2, Algorithms.findPositionIf(list,
22                                                                                             Bind.First(Predicates.EqualTo(), new Integer JavaDoc(2))
23                                                                                             ));
24     }
25
26   public void test2()
27   {
28     assertEquals(4, Algorithms.findPositionIf(list,
29                                                                                             Bind.First(Predicates.EqualTo(), new Integer JavaDoc(4))
30                                                                                             ));
31     }
32
33   public void test3()
34   {
35     assertEquals(7, Algorithms.findPositionIf(list,
36                                                                                             Bind.First(Predicates.EqualTo(), new Integer JavaDoc(7))
37                                                                                             ));
38     }
39
40   public void test4()
41   {
42     assertEquals(-1, Algorithms.findPositionIf(list,
43                                                                                             Bind.First(Predicates.EqualTo(), new Integer JavaDoc(99))
44                                                                                             ));
45     }
46
47   public void test5()
48   {
49     assertEquals(-1, Algorithms.findPositionIf(list,
50                                                                                              Bind.First(Predicates.EqualTo(), new String JavaDoc("charles dickens"))
51                                                                                              ));
52   } //
53
} // FindPositionIfTest
54
Popular Tags