KickJava   Java API By Example, From Geeks To Geeks.

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


1 package uk.co.jezuk.mango;
2
3 import junit.framework.*;
4
5 import java.util.List JavaDoc;
6 import java.util.ArrayList JavaDoc;
7
8 /**
9  * @version $Id: MutatingTest.java 649 2006-09-08 11:44:15Z jez $
10  */

11 public class UniqueTest extends TestCase
12 {
13     public UniqueTest(String JavaDoc name) { super(name); }
14   
15     public static Test suite() { return new TestSuite(UniqueTest.class); }
16
17     protected void setUp() { }
18     
19     public void test1()
20     {
21         List JavaDoc list = new ArrayList JavaDoc();
22         Algorithms.unique(list);
23     } // test1
24

25     public void test2()
26     {
27         List JavaDoc list = new ArrayList JavaDoc();
28         list.add("one");
29         
30         Algorithms.unique(list);
31         assertEquals(1, list.size());
32     } // test2
33

34     public void test3()
35     {
36         List JavaDoc list = new ArrayList JavaDoc();
37         list.add("one");
38         list.add("two");
39         
40         Algorithms.unique(list);
41         assertEquals(2, list.size());
42     } // test3
43

44     public void test4()
45     {
46         List JavaDoc list = new ArrayList JavaDoc();
47         list.add("one");
48         list.add("two");
49         list.add("three");
50         list.add("four");
51         list.add("five");
52         
53         Algorithms.unique(list);
54         assertEquals(5, list.size());
55     } // test4
56

57     public void test5()
58     {
59         List JavaDoc list = new ArrayList JavaDoc();
60         list.add("one");
61         list.add("two");
62         list.add("two");
63         list.add("three");
64         list.add("four");
65         list.add("five");
66         
67         Algorithms.unique(list);
68         assertEquals(5, list.size());
69     } // test5
70

71     public void test6()
72     {
73         List JavaDoc list = new ArrayList JavaDoc();
74         list.add("one");
75         list.add("two");
76         list.add("two");
77         list.add("two");
78         list.add("two");
79         list.add("two");
80         list.add("two");
81         list.add("two");
82         list.add("two");
83         list.add("two");
84         list.add("two");
85         list.add("two");
86         list.add("two");
87         list.add("three");
88         list.add("four");
89         list.add("five");
90         
91         Algorithms.unique(list);
92         assertEquals(5, list.size());
93     } // test6
94

95     public void test7()
96     {
97         List JavaDoc list = new ArrayList JavaDoc();
98         list.add("one");
99         list.add("one");
100         list.add("two");
101         list.add("two");
102         list.add("three");
103         list.add("three");
104         list.add("four");
105         list.add("four");
106         list.add("five");
107         list.add("five");
108         
109         Algorithms.unique(list);
110         assertEquals(5, list.size());
111     } // test6
112
} // class UniqueTest
113
Popular Tags