KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class SymmetricDifferenceTest extends TestCase
9 {
10     public SymmetricDifferenceTest(String JavaDoc name) { super(name); }
11     public static Test suite() { return new TestSuite(SymmetricDifferenceTest.class); }
12
13     public void test1()
14     {
15         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
16         Algorithms.symmetricDifference(l1, l1, l1);
17
18         assertEquals(0, l1.size());
19     } // test1
20

21     public void test2()
22     {
23         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
24         l1.add("1");
25         l1.add("2");
26         l1.add("3");
27         List JavaDoc i = new java.util.ArrayList JavaDoc();
28         Algorithms.symmetricDifference(l1, l1, i);
29         
30         assertEquals(0, i.size());
31     } // test2
32

33     public void test3()
34     {
35         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
36         l1.add("1");
37         l1.add("2");
38         l1.add("3");
39         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
40         l2.add("1");
41         l2.add("2");
42         l2.add("3");
43         List JavaDoc i = new java.util.ArrayList JavaDoc();
44         Algorithms.symmetricDifference(l1, l2, i);
45         
46         assertEquals(0, i.size());
47     } // test3
48

49     public void test4()
50     {
51         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
52         l1.add("1");
53         l1.add("2");
54         l1.add("3");
55         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
56         l2.add("1");
57         l2.add("3");
58         List JavaDoc i = new java.util.ArrayList JavaDoc();
59         Algorithms.symmetricDifference(l1, l2, i);
60         
61         assertEquals(1, i.size());
62         assertEquals("2", i.get(0));
63     } // test4
64

65     public void test5()
66     {
67         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
68         l1.add("1");
69         l1.add("2");
70         l1.add("3");
71         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
72         l2.add("2");
73         List JavaDoc i = new java.util.ArrayList JavaDoc();
74         Algorithms.symmetricDifference(l1, l2, i);
75         
76         assertEquals(2, i.size());
77         assertEquals("1", i.get(0));
78         assertEquals("3", i.get(1));
79     } // test5
80

81     public void test6()
82     {
83         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
84         l1.add("1");
85         l1.add("2");
86         l1.add("3");
87         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
88         l2.add("2");
89         l2.add("1");
90         List JavaDoc i = new java.util.ArrayList JavaDoc();
91         Algorithms.symmetricDifference(l1, l2, i);
92         
93         assertEquals(1, i.size());
94         assertEquals("3", i.get(0));
95     } // test6
96

97     public void test7()
98     {
99         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
100         l1.add("1");
101         l1.add("3");
102         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
103         l2.add("1");
104         l2.add("2");
105         l2.add("3");
106         List JavaDoc i = new java.util.ArrayList JavaDoc();
107         Algorithms.symmetricDifference(l1, l2, i);
108         
109         assertEquals(1, i.size());
110         assertEquals("2", i.get(0));
111     } // test7
112

113     public void test8()
114     {
115         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
116         l1.add("2");
117         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
118         l2.add("1");
119         l2.add("2");
120         l2.add("3");
121         List JavaDoc i = new java.util.ArrayList JavaDoc();
122         Algorithms.symmetricDifference(l1, l2, i);
123         
124         assertEquals(2, i.size());
125         assertEquals("1", i.get(0));
126         assertEquals("3", i.get(1));
127     } // test8
128

129     public void test9()
130     {
131         List JavaDoc l1 = new java.util.ArrayList JavaDoc();
132         l1.add("1");
133         l1.add("2");
134         l1.add("3");
135         List JavaDoc l2 = new java.util.ArrayList JavaDoc();
136         l2.add("4");
137         l2.add("5");
138         l2.add("6");
139         List JavaDoc i = new java.util.ArrayList JavaDoc();
140         Algorithms.symmetricDifference(l1, l2, i);
141         
142         assertEquals(6, i.size());
143         assertEquals("1", i.get(0));
144         assertEquals("2", i.get(1));
145         assertEquals("3", i.get(2));
146         assertEquals("4", i.get(3));
147         assertEquals("5", i.get(4));
148         assertEquals("6", i.get(5));
149     } // test9
150
} // class SymmetricDifferenceTest
151
Popular Tags