1 17 package org.apache.commons.collections.primitives; 18 19 import junit.framework.Test; 20 import junit.framework.TestSuite; 21 22 import org.apache.commons.collections.BulkTest; 23 24 28 public class TestArrayBooleanList extends TestBooleanList { 29 30 33 public TestArrayBooleanList(String testName) { 34 super(testName); 35 } 36 37 public static Test suite() { 38 TestSuite suite = BulkTest.makeSuite(TestArrayBooleanList.class); 39 return suite; 40 } 41 42 45 protected BooleanList makeEmptyBooleanList() { 46 return new ArrayBooleanList(); 47 } 48 49 public String [] ignoredTests() { 50 return new String [] { 51 52 "TestArrayBooleanList.bulkTestSubList.testListEquals", 54 "TestArrayBooleanList.bulkTestSubList.testCollectionRemoveAll", 55 "TestArrayBooleanList.bulkTestSubList.testCollectionRetainAll", 56 57 "TestArrayBooleanList.bulkTestSubList.testFullListSerialization", 59 "TestArrayBooleanList.bulkTestSubList.testEmptyListSerialization", 60 "TestArrayBooleanList.bulkTestSubList.testCanonicalEmptyCollectionExists", 61 "TestArrayBooleanList.bulkTestSubList.testCanonicalFullCollectionExists", 62 "TestArrayBooleanList.bulkTestSubList.testEmptyListCompatibility", 63 "TestArrayBooleanList.bulkTestSubList.testFullListCompatibility", 64 "TestArrayBooleanList.bulkTestSubList.testSerializeDeserializeThenCompare", 65 "TestArrayBooleanList.bulkTestSubList.testSimpleSerialization" 66 }; 67 } 68 69 72 73 public void testCanonicalEmptyCollectionExists() { 74 } 77 78 public void testCanonicalFullCollectionExists() { 79 } 82 83 public void testEmptyListCompatibility() { 84 } 87 88 public void testFullListCompatibility() { 89 } 92 93 public void testZeroInitialCapacityIsValid() { 94 assertNotNull(new ArrayBooleanList(0)); 95 } 96 97 public void testNegativeInitialCapacityIsInvalid() { 98 try { 99 new ArrayBooleanList(-1); 100 fail("Expected IllegalArgumentException"); 101 } catch(IllegalArgumentException e) { 102 } 104 } 105 106 public void testCopyConstructor() { 107 ArrayBooleanList expected = new ArrayBooleanList(); 108 for(int i=0;i<10;i++) { 109 expected.add(i%2==0); 110 } 111 ArrayBooleanList list = new ArrayBooleanList(expected); 112 assertEquals(10,list.size()); 113 assertEquals(expected,list); 114 } 115 116 public void testCopyConstructorWithNull() { 117 try { 118 new ArrayBooleanList((BooleanCollection) null); 119 fail("Expected NullPointerException"); 120 } catch(NullPointerException e) { 121 } 123 } 124 125 public void testArrayConstructor() { 126 ArrayBooleanList expected = new ArrayBooleanList(); 127 for (int i = 0; i < 10; i++) { 128 expected.add(i % 2 == 0); 129 } 130 ArrayBooleanList list = new ArrayBooleanList(expected.toArray()); 131 assertEquals(10, list.size()); 132 assertEquals(expected, list); 133 } 134 135 public void testArrayConstructorWithNull() { 136 try { 137 new ArrayBooleanList((boolean[]) null); 138 fail("Expected NullPointerException"); 139 } catch (NullPointerException e) { 140 } 142 } 143 144 145 public void testTrimToSize() { 146 ArrayBooleanList list = new ArrayBooleanList(); 147 for(int j=0;j<3;j++) { 148 assertTrue(list.isEmpty()); 149 150 list.trimToSize(); 151 152 assertTrue(list.isEmpty()); 153 154 for(int i=0;i<10;i++) { 155 list.add(i%2==0); 156 } 157 158 for(int i=0;i<10;i++) { 159 assertEquals(i%2==0,list.get(i)); 160 } 161 162 list.trimToSize(); 163 164 for(int i=0;i<10;i++) { 165 assertEquals(i%2==0,list.get(i)); 166 } 167 168 for(int i=0;i<5;i++) { 169 list.removeElement(true); 170 } 171 172 for(int i=0;i<5;i++) { 173 assertEquals(false,list.get(i)); 174 } 175 176 list.trimToSize(); 177 178 for(int i=0;i<5;i++) { 179 assertEquals(false,list.get(i)); 180 } 181 182 list.trimToSize(); 183 184 for(int i=0;i<5;i++) { 185 assertEquals(false,list.get(i)); 186 } 187 188 list.clear(); 189 } 190 } 191 192 } 193 | Popular Tags |