1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
25
26
27
28 public class TestArrayUnsignedIntList extends TestLongList {
29
30
31
32
33 public TestArrayUnsignedIntList(String testName) {
34 super(testName);
35 }
36
37 public static Test suite() {
38 TestSuite suite = BulkTest.makeSuite(TestArrayUnsignedIntList.class);
39 return suite;
40 }
41
42
43
44
45 protected LongList makeEmptyLongList() {
46 return new ArrayUnsignedIntList();
47 }
48
49 public String[] ignoredTests() {
50
51 return new String[] {
52 "TestArrayUnsignedLongList.bulkTestSubList.testFullListSerialization",
53 "TestArrayUnsignedLongList.bulkTestSubList.testEmptyListSerialization",
54 "TestArrayUnsignedLongList.bulkTestSubList.testCanonicalEmptyCollectionExists",
55 "TestArrayUnsignedLongList.bulkTestSubList.testCanonicalFullCollectionExists",
56 "TestArrayUnsignedLongList.bulkTestSubList.testEmptyListCompatibility",
57 "TestArrayUnsignedLongList.bulkTestSubList.testFullListCompatibility",
58 "TestArrayUnsignedLongList.bulkTestSubList.testSerializeDeserializeThenCompare",
59 "TestArrayUnsignedLongList.bulkTestSubList.testSimpleSerialization"
60 };
61 }
62
63 protected long[] getFullLongs() {
64 long[] result = new long[19];
65 for(int i = 0; i < result.length; i++) {
66 result[i] = ((long)Integer.MAX_VALUE - 1L - (long)i);
67 }
68 return result;
69 }
70
71
72
73
74 public void testArrayConstructor() {
75 long[] data = new long[] { 1, 2, 3 };
76 LongList list = new ArrayUnsignedIntList(data);
77 for(int i=0;i<data.length;i++) {
78 assertEquals(data[i],list.get(i));
79 }
80 data[0] = 17;
81 assertEquals(1,list.get(0));
82 }
83
84
85 public void testCanonicalEmptyCollectionExists() {
86
87
88 }
89
90 public void testCanonicalFullCollectionExists() {
91
92
93 }
94
95 public void testEmptyListCompatibility() {
96
97
98 }
99
100 public void testFullListCompatibility() {
101
102
103 }
104
105 public void testZeroInitialCapacityIsValid() {
106 assertNotNull(new ArrayUnsignedIntList(0));
107 }
108
109 public void testIllegalArgumentExceptionWhenElementOutOfRange() {
110 ArrayUnsignedIntList list = new ArrayUnsignedIntList();
111 list.add(ArrayUnsignedIntList.MIN_VALUE);
112 list.add(ArrayUnsignedIntList.MAX_VALUE);
113 try {
114 list.add(-1);
115 fail("Expected IllegalArgumentException");
116 } catch(IllegalArgumentException e) {
117
118 }
119 try {
120 list.add(ArrayUnsignedIntList.MAX_VALUE+1);
121 fail("Expected IllegalArgumentException");
122 } catch(IllegalArgumentException e) {
123
124 }
125 }
126
127 public void testNegativeInitialCapacityIsInvalid() {
128 try {
129 new ArrayUnsignedIntList(-1);
130 fail("Expected IllegalArgumentException");
131 } catch(IllegalArgumentException e) {
132
133 }
134 }
135
136 public void testCopyConstructor() {
137 ArrayUnsignedIntList expected = new ArrayUnsignedIntList();
138 for(int i=0;i<10;i++) {
139 expected.add(i);
140 }
141 ArrayUnsignedIntList list = new ArrayUnsignedIntList(expected);
142 assertEquals(10,list.size());
143 assertEquals(expected,list);
144 }
145
146 public void testCopyConstructorWithNull() {
147 try {
148 new ArrayUnsignedIntList((LongList)null);
149 fail("Expected NullPointerException");
150 } catch(NullPointerException e) {
151
152 }
153 }
154
155
156 public void testTrimToSize() {
157 ArrayUnsignedIntList list = new ArrayUnsignedIntList();
158 for(int j=0;j<3;j++) {
159 assertTrue(list.isEmpty());
160
161 list.trimToSize();
162
163 assertTrue(list.isEmpty());
164
165 for(int i=0;i<10;i++) {
166 list.add(i);
167 }
168
169 for(int i=0;i<10;i++) {
170 assertEquals(i,list.get(i));
171 }
172
173 list.trimToSize();
174
175 for(int i=0;i<10;i++) {
176 assertEquals(i,list.get(i));
177 }
178
179 for(int i=0;i<10;i+=2) {
180 list.removeElement(i);
181 }
182
183 for(int i=0;i<5;i++) {
184 assertEquals((2*i)+1,list.get(i));
185 }
186
187 list.trimToSize();
188
189 for(int i=0;i<5;i++) {
190 assertEquals((2*i)+1,list.get(i));
191 }
192
193 list.trimToSize();
194
195 for(int i=0;i<5;i++) {
196 assertEquals((2*i)+1,list.get(i));
197 }
198
199 list.clear();
200 }
201 }
202
203 }