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 TestArrayUnsignedShortList extends TestIntList { 29 30 33 public TestArrayUnsignedShortList(String testName) { 34 super(testName); 35 } 36 37 public static Test suite() { 38 TestSuite suite = BulkTest.makeSuite(TestArrayUnsignedShortList.class); 39 return suite; 40 } 41 42 45 protected IntList makeEmptyIntList() { 46 return new ArrayUnsignedShortList(); 47 } 48 49 public String [] ignoredTests() { 50 return new String [] { 52 "TestArrayUnsignedShortList.bulkTestSubList.testFullListSerialization", 53 "TestArrayUnsignedShortList.bulkTestSubList.testEmptyListSerialization", 54 "TestArrayUnsignedShortList.bulkTestSubList.testCanonicalEmptyCollectionExists", 55 "TestArrayUnsignedShortList.bulkTestSubList.testCanonicalFullCollectionExists", 56 "TestArrayUnsignedShortList.bulkTestSubList.testEmptyListCompatibility", 57 "TestArrayUnsignedShortList.bulkTestSubList.testFullListCompatibility", 58 "TestArrayUnsignedShortList.bulkTestSubList.testSerializeDeserializeThenCompare", 59 "TestArrayUnsignedShortList.bulkTestSubList.testSimpleSerialization" 60 }; 61 } 62 63 66 public void testArrayConstructor() { 67 int[] data = new int[] { 1, 2, 3 }; 68 IntList list = new ArrayUnsignedShortList(data); 69 for(int i=0;i<data.length;i++) { 70 assertEquals(data[i],list.get(i)); 71 } 72 data[0] = 17; 73 assertEquals(1,list.get(0)); 74 } 75 76 public void testCanonicalEmptyCollectionExists() { 78 } 81 82 public void testCanonicalFullCollectionExists() { 83 } 86 87 public void testEmptyListCompatibility() { 88 } 91 92 public void testFullListCompatibility() { 93 } 96 97 public void testZeroInitialCapacityIsValid() { 98 assertNotNull(new ArrayUnsignedShortList(0)); 99 } 100 101 public void testIllegalArgumentExceptionWhenElementOutOfRange() { 102 ArrayUnsignedShortList list = new ArrayUnsignedShortList(); 103 list.add(ArrayUnsignedShortList.MIN_VALUE); 104 list.add(ArrayUnsignedShortList.MAX_VALUE); 105 try { 106 list.add(-1); 107 fail("Expected IllegalArgumentException"); 108 } catch(IllegalArgumentException e) { 109 } 111 try { 112 list.add(ArrayUnsignedShortList.MAX_VALUE+1); 113 fail("Expected IllegalArgumentException"); 114 } catch(IllegalArgumentException e) { 115 } 117 } 118 119 public void testNegativeInitialCapacityIsInvalid() { 120 try { 121 new ArrayUnsignedShortList(-1); 122 fail("Expected IllegalArgumentException"); 123 } catch(IllegalArgumentException e) { 124 } 126 } 127 128 public void testCopyConstructor() { 129 ArrayUnsignedShortList expected = new ArrayUnsignedShortList(); 130 for(int i=0;i<10;i++) { 131 expected.add(i); 132 } 133 ArrayUnsignedShortList list = new ArrayUnsignedShortList(expected); 134 assertEquals(10,list.size()); 135 assertEquals(expected,list); 136 } 137 138 public void testCopyConstructorWithNull() { 139 try { 140 new ArrayUnsignedShortList((IntList)null); 141 fail("Expected NullPointerException"); 142 } catch(NullPointerException e) { 143 } 145 } 146 147 148 public void testTrimToSize() { 149 ArrayUnsignedShortList list = new ArrayUnsignedShortList(); 150 for(int j=0;j<3;j++) { 151 assertTrue(list.isEmpty()); 152 153 list.trimToSize(); 154 155 assertTrue(list.isEmpty()); 156 157 for(int i=0;i<10;i++) { 158 list.add(i); 159 } 160 161 for(int i=0;i<10;i++) { 162 assertEquals(i,list.get(i)); 163 } 164 165 list.trimToSize(); 166 167 for(int i=0;i<10;i++) { 168 assertEquals(i,list.get(i)); 169 } 170 171 for(int i=0;i<10;i+=2) { 172 list.removeElement(i); 173 } 174 175 for(int i=0;i<5;i++) { 176 assertEquals((2*i)+1,list.get(i)); 177 } 178 179 list.trimToSize(); 180 181 for(int i=0;i<5;i++) { 182 assertEquals((2*i)+1,list.get(i)); 183 } 184 185 list.trimToSize(); 186 187 for(int i=0;i<5;i++) { 188 assertEquals((2*i)+1,list.get(i)); 189 } 190 191 list.clear(); 192 } 193 } 194 195 } 196 | Popular Tags |