01: package net.sf.clirr.core.internal;
02:
03: import java.util.ArrayList;
04: import junit.framework.TestCase;
05: import net.sf.clirr.core.internal.CoIterator;
06:
07: /**
08: * Tests for the CoIterator class.
09: */
10: public class CoIteratorTest extends TestCase {
11: public void testBasics() {
12: ArrayList coll1 = new ArrayList();
13: ArrayList coll2 = new ArrayList();
14:
15: coll1.add("delta");
16: coll1.add("beta");
17: coll1.add("echo");
18: coll1.add("foxtrot");
19:
20: coll2.add("delta");
21: coll2.add("beta");
22: coll2.add("foxtrot");
23: coll2.add("alpha");
24: coll2.add("golf");
25: coll2.add("hotel");
26:
27: CoIterator iter = new CoIterator(null, coll1, coll2);
28:
29: ArrayList lefts = new ArrayList();
30: ArrayList rights = new ArrayList();
31:
32: while (iter.hasNext()) {
33: iter.next();
34: lefts.add(iter.getLeft());
35: rights.add(iter.getRight());
36: }
37:
38: int coll1Size = coll1.size();
39: int coll2Size = coll2.size();
40: assertEquals(7, lefts.size());
41: assertEquals(7, rights.size());
42:
43: assertEquals("lefts should not have alpha", null, lefts.get(0));
44: assertEquals("rights should have alpha", "alpha", rights.get(0));
45:
46: assertEquals("lefts should have beta", "beta", lefts.get(1));
47: assertEquals("rights should have beta", "beta", rights.get(1));
48:
49: assertEquals("delta", lefts.get(2));
50: assertEquals("delta", rights.get(2));
51:
52: assertEquals("echo", lefts.get(3));
53: assertEquals(null, rights.get(3));
54:
55: assertEquals("foxtrot", lefts.get(4));
56: assertEquals("foxtrot", rights.get(4));
57:
58: assertEquals(null, lefts.get(5));
59: assertEquals("golf", rights.get(5));
60:
61: assertEquals(null, lefts.get(6));
62: assertEquals("hotel", rights.get(6));
63: }
64: }
|