KickJava   Java API By Example, From Geeks To Geeks.

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


1 package uk.co.jezuk.mango;
2
3 import junit.framework.*;
4
5 public class FindPositionTest extends TestCase
6 {
7   java.util.List JavaDoc list;
8
9   public FindPositionTest(String JavaDoc name) { super(name); }
10   public static Test suite() { return new TestSuite(FindPositionTest.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.findPosition(list, new Integer JavaDoc(2)));
22     }
23
24   public void test2()
25   {
26     assertEquals(4, Algorithms.findPosition(list, new Integer JavaDoc(4)));
27     }
28
29   public void test3()
30   {
31     assertEquals(7, Algorithms.findPosition(list, new Integer JavaDoc(7)));
32     }
33
34   public void test4()
35   {
36     assertEquals(-1, Algorithms.findPosition(list, new Integer JavaDoc(99)));
37     }
38
39   public void test5()
40   {
41     assertEquals(-1, Algorithms.findPosition(list, new String JavaDoc("charles dickens")));
42   } //
43
} // FindPositionTest
44
Popular Tags