1 package uk.co.jezuk.mango; 2 3 import junit.framework.*; 4 5 import java.util.List ; 6 import java.util.ArrayList ; 7 8 public class IntersectionTest extends TestCase 9 { 10 public IntersectionTest(String name) { super(name); } 11 public static Test suite() { return new TestSuite(IntersectionTest.class); } 12 13 public void test1() 14 { 15 List l1 = new java.util.ArrayList (); 16 Algorithms.intersection(l1, l1, l1); 17 18 assertEquals(0, l1.size()); 19 } 21 public void test2() 22 { 23 List l1 = new java.util.ArrayList (); 24 l1.add("1"); 25 l1.add("2"); 26 l1.add("3"); 27 List i = new java.util.ArrayList (); 28 Algorithms.intersection(l1, l1, i); 29 30 assertEquals(3, i.size()); 31 assertEquals("1", i.get(0)); 32 assertEquals("2", i.get(1)); 33 assertEquals("3", i.get(2)); 34 } 36 public void test3() 37 { 38 List l1 = new java.util.ArrayList (); 39 l1.add("1"); 40 l1.add("2"); 41 l1.add("3"); 42 List l2 = new java.util.ArrayList (); 43 l2.add("1"); 44 l2.add("2"); 45 l2.add("3"); 46 List i = new java.util.ArrayList (); 47 Algorithms.intersection(l1, l2, i); 48 49 assertEquals(3, i.size()); 50 assertEquals("1", i.get(0)); 51 assertEquals("2", i.get(1)); 52 assertEquals("3", i.get(2)); 53 } 55 public void test4() 56 { 57 List l1 = new java.util.ArrayList (); 58 l1.add("1"); 59 l1.add("2"); 60 l1.add("3"); 61 List l2 = new java.util.ArrayList (); 62 l2.add("1"); 63 l2.add("3"); 64 List i = new java.util.ArrayList (); 65 Algorithms.intersection(l1, l2, i); 66 67 assertEquals(2, i.size()); 68 assertEquals("1", i.get(0)); 69 assertEquals("3", i.get(1)); 70 } 72 public void test5() 73 { 74 List l1 = new java.util.ArrayList (); 75 l1.add("1"); 76 l1.add("2"); 77 l1.add("3"); 78 List l2 = new java.util.ArrayList (); 79 l2.add("2"); 80 List i = new java.util.ArrayList (); 81 Algorithms.intersection(l1, l2, i); 82 83 assertEquals(1, i.size()); 84 assertEquals("2", i.get(0)); 85 } 87 public void test6() 88 { 89 List l1 = new java.util.ArrayList (); 90 l1.add("1"); 91 l1.add("2"); 92 l1.add("3"); 93 List l2 = new java.util.ArrayList (); 94 l2.add("2"); 95 l2.add("1"); 96 List i = new java.util.ArrayList (); 97 Algorithms.intersection(l1, l2, i); 98 99 assertEquals(2, i.size()); 100 assertEquals("1", i.get(0)); 101 assertEquals("2", i.get(1)); 102 } 104 public void test7() 105 { 106 List l1 = new java.util.ArrayList (); 107 l1.add("1"); 108 l1.add("3"); 109 List l2 = new java.util.ArrayList (); 110 l2.add("1"); 111 l2.add("2"); 112 l2.add("3"); 113 List i = new java.util.ArrayList (); 114 Algorithms.intersection(l1, l2, i); 115 116 assertEquals(2, i.size()); 117 assertEquals("1", i.get(0)); 118 assertEquals("3", i.get(1)); 119 } 121 public void test8() 122 { 123 List l1 = new java.util.ArrayList (); 124 l1.add("2"); 125 List l2 = new java.util.ArrayList (); 126 l2.add("1"); 127 l2.add("2"); 128 l2.add("3"); 129 List i = new java.util.ArrayList (); 130 Algorithms.intersection(l1, l2, i); 131 132 assertEquals(1, i.size()); 133 assertEquals("2", i.get(0)); 134 } 136 public void test9() 137 { 138 List l1 = new java.util.ArrayList (); 139 l1.add("1"); 140 l1.add("2"); 141 l1.add("3"); 142 List l2 = new java.util.ArrayList (); 143 l2.add("4"); 144 l2.add("5"); 145 l2.add("6"); 146 List i = new java.util.ArrayList (); 147 Algorithms.intersection(l1, l2, i); 148 149 assertEquals(0, i.size()); 150 } } | Popular Tags |