11 |
|
import java.util.concurrent.*; |
12 |
|
import java.io.*; |
13 |
|
|
14 |
< |
public class CopyOnWriteArrayListTest extends JSR166TestCase{ |
14 |
> |
public class CopyOnWriteArrayListTest extends JSR166TestCase { |
15 |
|
|
16 |
|
public static void main(String[] args) { |
17 |
< |
junit.textui.TestRunner.run (suite()); |
17 |
> |
junit.textui.TestRunner.run (suite()); |
18 |
|
} |
19 |
|
|
20 |
|
public static Test suite() { |
21 |
< |
return new TestSuite(CopyOnWriteArrayListTest.class); |
21 |
> |
return new TestSuite(CopyOnWriteArrayListTest.class); |
22 |
|
} |
23 |
|
|
24 |
< |
static CopyOnWriteArrayList populatedArray(int n){ |
25 |
< |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(); |
24 |
> |
static CopyOnWriteArrayList populatedArray(int n) { |
25 |
> |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(); |
26 |
|
assertTrue(a.isEmpty()); |
27 |
|
for (int i = 0; i < n; ++i) |
28 |
|
a.add(new Integer(i)); |
36 |
|
* a new list is empty |
37 |
|
*/ |
38 |
|
public void testConstructor() { |
39 |
< |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(); |
39 |
> |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(); |
40 |
|
assertTrue(a.isEmpty()); |
41 |
|
} |
42 |
|
|
47 |
|
Integer[] ints = new Integer[SIZE]; |
48 |
|
for (int i = 0; i < SIZE-1; ++i) |
49 |
|
ints[i] = new Integer(i); |
50 |
< |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(ints); |
50 |
> |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(ints); |
51 |
|
for (int i = 0; i < SIZE; ++i) |
52 |
|
assertEquals(ints[i], a.get(i)); |
53 |
|
} |
59 |
|
Integer[] ints = new Integer[SIZE]; |
60 |
|
for (int i = 0; i < SIZE-1; ++i) |
61 |
|
ints[i] = new Integer(i); |
62 |
< |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(Arrays.asList(ints)); |
62 |
> |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(Arrays.asList(ints)); |
63 |
|
for (int i = 0; i < SIZE; ++i) |
64 |
|
assertEquals(ints[i], a.get(i)); |
65 |
|
} |
69 |
|
* addAll adds each element from the given collection |
70 |
|
*/ |
71 |
|
public void testAddAll() { |
72 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
73 |
< |
Vector v = new Vector(); |
74 |
< |
v.add(three); |
75 |
< |
v.add(four); |
76 |
< |
v.add(five); |
77 |
< |
full.addAll(v); |
78 |
< |
assertEquals(6, full.size()); |
72 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
73 |
> |
Vector v = new Vector(); |
74 |
> |
v.add(three); |
75 |
> |
v.add(four); |
76 |
> |
v.add(five); |
77 |
> |
full.addAll(v); |
78 |
> |
assertEquals(6, full.size()); |
79 |
|
} |
80 |
|
|
81 |
|
/** |
83 |
|
* already exist in the List |
84 |
|
*/ |
85 |
|
public void testAddAllAbsent() { |
86 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
87 |
< |
Vector v = new Vector(); |
88 |
< |
v.add(three); |
89 |
< |
v.add(four); |
90 |
< |
v.add(one); // will not add this element |
91 |
< |
full.addAllAbsent(v); |
92 |
< |
assertEquals(5, full.size()); |
86 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
87 |
> |
Vector v = new Vector(); |
88 |
> |
v.add(three); |
89 |
> |
v.add(four); |
90 |
> |
v.add(one); // will not add this element |
91 |
> |
full.addAllAbsent(v); |
92 |
> |
assertEquals(5, full.size()); |
93 |
|
} |
94 |
|
|
95 |
|
/** |
96 |
|
* addIfAbsent will not add the element if it already exists in the list |
97 |
|
*/ |
98 |
|
public void testAddIfAbsent() { |
99 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
100 |
< |
full.addIfAbsent(one); |
101 |
< |
assertEquals(SIZE, full.size()); |
99 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
100 |
> |
full.addIfAbsent(one); |
101 |
> |
assertEquals(SIZE, full.size()); |
102 |
|
} |
103 |
|
|
104 |
|
/** |
105 |
|
* addIfAbsent adds the element when it does not exist in the list |
106 |
|
*/ |
107 |
|
public void testAddIfAbsent2() { |
108 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
108 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
109 |
|
full.addIfAbsent(three); |
110 |
|
assertTrue(full.contains(three)); |
111 |
|
} |
114 |
|
* clear removes all elements from the list |
115 |
|
*/ |
116 |
|
public void testClear() { |
117 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
118 |
< |
full.clear(); |
119 |
< |
assertEquals(0, full.size()); |
117 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
118 |
> |
full.clear(); |
119 |
> |
assertEquals(0, full.size()); |
120 |
|
} |
121 |
|
|
122 |
|
|
124 |
|
* Cloned list is equal |
125 |
|
*/ |
126 |
|
public void testClone() { |
127 |
< |
CopyOnWriteArrayList l1 = populatedArray(SIZE); |
128 |
< |
CopyOnWriteArrayList l2 = (CopyOnWriteArrayList)(l1.clone()); |
127 |
> |
CopyOnWriteArrayList l1 = populatedArray(SIZE); |
128 |
> |
CopyOnWriteArrayList l2 = (CopyOnWriteArrayList)(l1.clone()); |
129 |
|
assertEquals(l1, l2); |
130 |
< |
l1.clear(); |
130 |
> |
l1.clear(); |
131 |
|
assertFalse(l1.equals(l2)); |
132 |
|
} |
133 |
|
|
135 |
|
* contains is true for added elements |
136 |
|
*/ |
137 |
|
public void testContains() { |
138 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
139 |
< |
assertTrue(full.contains(one)); |
140 |
< |
assertFalse(full.contains(five)); |
138 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
139 |
> |
assertTrue(full.contains(one)); |
140 |
> |
assertFalse(full.contains(five)); |
141 |
|
} |
142 |
|
|
143 |
|
/** |
144 |
|
* adding at an index places it in the indicated index |
145 |
|
*/ |
146 |
|
public void testAddIndex() { |
147 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
147 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
148 |
|
full.add(0, m1); |
149 |
|
assertEquals(4, full.size()); |
150 |
|
assertEquals(m1, full.get(0)); |
160 |
|
* lists with same elements are equal and have same hashCode |
161 |
|
*/ |
162 |
|
public void testEquals() { |
163 |
< |
CopyOnWriteArrayList a = populatedArray(3); |
164 |
< |
CopyOnWriteArrayList b = populatedArray(3); |
163 |
> |
CopyOnWriteArrayList a = populatedArray(3); |
164 |
> |
CopyOnWriteArrayList b = populatedArray(3); |
165 |
|
assertTrue(a.equals(b)); |
166 |
|
assertTrue(b.equals(a)); |
167 |
|
assertEquals(a.hashCode(), b.hashCode()); |
179 |
|
* containsAll returns true for collection with subset of elements |
180 |
|
*/ |
181 |
|
public void testContainsAll() { |
182 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
183 |
< |
Vector v = new Vector(); |
184 |
< |
v.add(one); |
185 |
< |
v.add(two); |
186 |
< |
assertTrue(full.containsAll(v)); |
187 |
< |
v.add(six); |
188 |
< |
assertFalse(full.containsAll(v)); |
182 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
183 |
> |
Vector v = new Vector(); |
184 |
> |
v.add(one); |
185 |
> |
v.add(two); |
186 |
> |
assertTrue(full.containsAll(v)); |
187 |
> |
v.add(six); |
188 |
> |
assertFalse(full.containsAll(v)); |
189 |
|
} |
190 |
|
|
191 |
|
/** |
192 |
|
* get returns the value at the given index |
193 |
|
*/ |
194 |
|
public void testGet() { |
195 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
196 |
< |
assertEquals(0, ((Integer)full.get(0)).intValue()); |
195 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
196 |
> |
assertEquals(0, ((Integer)full.get(0)).intValue()); |
197 |
|
} |
198 |
|
|
199 |
|
/** |
200 |
|
* indexOf gives the index for the given object |
201 |
|
*/ |
202 |
|
public void testIndexOf() { |
203 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
204 |
< |
assertEquals(1, full.indexOf(one)); |
205 |
< |
assertEquals(-1, full.indexOf("puppies")); |
203 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
204 |
> |
assertEquals(1, full.indexOf(one)); |
205 |
> |
assertEquals(-1, full.indexOf("puppies")); |
206 |
|
} |
207 |
|
|
208 |
|
/** |
210 |
|
* at which to start searching |
211 |
|
*/ |
212 |
|
public void testIndexOf2() { |
213 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
214 |
< |
assertEquals(1, full.indexOf(one, 0)); |
215 |
< |
assertEquals(-1, full.indexOf(one, 2)); |
213 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
214 |
> |
assertEquals(1, full.indexOf(one, 0)); |
215 |
> |
assertEquals(-1, full.indexOf(one, 2)); |
216 |
|
} |
217 |
|
|
218 |
|
/** |
219 |
|
* isEmpty returns true when empty, else false |
220 |
|
*/ |
221 |
|
public void testIsEmpty() { |
222 |
< |
CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); |
223 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
224 |
< |
assertTrue(empty.isEmpty()); |
225 |
< |
assertFalse(full.isEmpty()); |
222 |
> |
CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); |
223 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
224 |
> |
assertTrue(empty.isEmpty()); |
225 |
> |
assertFalse(full.isEmpty()); |
226 |
|
} |
227 |
|
|
228 |
|
/** |
229 |
|
* iterator() returns an iterator containing the elements of the list |
230 |
|
*/ |
231 |
|
public void testIterator() { |
232 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
233 |
< |
Iterator i = full.iterator(); |
234 |
< |
int j; |
235 |
< |
for(j = 0; i.hasNext(); j++) |
236 |
< |
assertEquals(j, ((Integer)i.next()).intValue()); |
237 |
< |
assertEquals(SIZE, j); |
232 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
233 |
> |
Iterator i = full.iterator(); |
234 |
> |
int j; |
235 |
> |
for (j = 0; i.hasNext(); j++) |
236 |
> |
assertEquals(j, ((Integer)i.next()).intValue()); |
237 |
> |
assertEquals(SIZE, j); |
238 |
|
} |
239 |
|
|
240 |
|
/** |
241 |
|
* iterator.remove throws UnsupportedOperationException |
242 |
|
*/ |
243 |
|
public void testIteratorRemove () { |
244 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
244 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
245 |
|
Iterator it = full.iterator(); |
246 |
|
it.next(); |
247 |
|
try { |
255 |
|
* toString contains toString of elements |
256 |
|
*/ |
257 |
|
public void testToString() { |
258 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
258 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
259 |
|
String s = full.toString(); |
260 |
|
for (int i = 0; i < 3; ++i) { |
261 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
266 |
|
* lastIndexOf returns the index for the given object |
267 |
|
*/ |
268 |
|
public void testLastIndexOf1() { |
269 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
270 |
< |
full.add(one); |
271 |
< |
full.add(three); |
272 |
< |
assertEquals(3, full.lastIndexOf(one)); |
273 |
< |
assertEquals(-1, full.lastIndexOf(six)); |
269 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
270 |
> |
full.add(one); |
271 |
> |
full.add(three); |
272 |
> |
assertEquals(3, full.lastIndexOf(one)); |
273 |
> |
assertEquals(-1, full.lastIndexOf(six)); |
274 |
|
} |
275 |
|
|
276 |
|
/** |
277 |
|
* lastIndexOf returns the index from the given starting point |
278 |
|
*/ |
279 |
|
public void testlastIndexOf2() { |
280 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
281 |
< |
full.add(one); |
282 |
< |
full.add(three); |
283 |
< |
assertEquals(3, full.lastIndexOf(one, 4)); |
284 |
< |
assertEquals(-1, full.lastIndexOf(three, 3)); |
280 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
281 |
> |
full.add(one); |
282 |
> |
full.add(three); |
283 |
> |
assertEquals(3, full.lastIndexOf(one, 4)); |
284 |
> |
assertEquals(-1, full.lastIndexOf(three, 3)); |
285 |
|
} |
286 |
|
|
287 |
|
/** |
288 |
|
* listIterator traverses all elements |
289 |
|
*/ |
290 |
|
public void testListIterator1() { |
291 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
292 |
< |
ListIterator i = full.listIterator(); |
293 |
< |
int j; |
294 |
< |
for(j = 0; i.hasNext(); j++) |
295 |
< |
assertEquals(j, ((Integer)i.next()).intValue()); |
296 |
< |
assertEquals(SIZE, j); |
291 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
292 |
> |
ListIterator i = full.listIterator(); |
293 |
> |
int j; |
294 |
> |
for (j = 0; i.hasNext(); j++) |
295 |
> |
assertEquals(j, ((Integer)i.next()).intValue()); |
296 |
> |
assertEquals(SIZE, j); |
297 |
|
} |
298 |
|
|
299 |
|
/** |
300 |
|
* listIterator only returns those elements after the given index |
301 |
|
*/ |
302 |
|
public void testListIterator2() { |
303 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
304 |
< |
ListIterator i = full.listIterator(1); |
305 |
< |
int j; |
306 |
< |
for(j = 0; i.hasNext(); j++) |
307 |
< |
assertEquals(j+1, ((Integer)i.next()).intValue()); |
308 |
< |
assertEquals(2, j); |
303 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
304 |
> |
ListIterator i = full.listIterator(1); |
305 |
> |
int j; |
306 |
> |
for (j = 0; i.hasNext(); j++) |
307 |
> |
assertEquals(j+1, ((Integer)i.next()).intValue()); |
308 |
> |
assertEquals(2, j); |
309 |
|
} |
310 |
|
|
311 |
|
/** |
312 |
|
* remove removes and returns the object at the given index |
313 |
|
*/ |
314 |
|
public void testRemove() { |
315 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
316 |
< |
assertEquals(two, full.remove(2)); |
317 |
< |
assertEquals(2, full.size()); |
315 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
316 |
> |
assertEquals(two, full.remove(2)); |
317 |
> |
assertEquals(2, full.size()); |
318 |
|
} |
319 |
|
|
320 |
|
/** |
321 |
|
* removeAll removes all elements from the given collection |
322 |
|
*/ |
323 |
|
public void testRemoveAll() { |
324 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
325 |
< |
Vector v = new Vector(); |
326 |
< |
v.add(one); |
327 |
< |
v.add(two); |
328 |
< |
full.removeAll(v); |
329 |
< |
assertEquals(1, full.size()); |
324 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
325 |
> |
Vector v = new Vector(); |
326 |
> |
v.add(one); |
327 |
> |
v.add(two); |
328 |
> |
full.removeAll(v); |
329 |
> |
assertEquals(1, full.size()); |
330 |
|
} |
331 |
|
|
332 |
|
/** |
333 |
|
* set changes the element at the given index |
334 |
|
*/ |
335 |
|
public void testSet() { |
336 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
337 |
< |
assertEquals(two, full.set(2, four)); |
338 |
< |
assertEquals(4, ((Integer)full.get(2)).intValue()); |
336 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
337 |
> |
assertEquals(two, full.set(2, four)); |
338 |
> |
assertEquals(4, ((Integer)full.get(2)).intValue()); |
339 |
|
} |
340 |
|
|
341 |
|
/** |
342 |
|
* size returns the number of elements |
343 |
|
*/ |
344 |
|
public void testSize() { |
345 |
< |
CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); |
346 |
< |
CopyOnWriteArrayList full = populatedArray(SIZE); |
347 |
< |
assertEquals(SIZE, full.size()); |
348 |
< |
assertEquals(0, empty.size()); |
345 |
> |
CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); |
346 |
> |
CopyOnWriteArrayList full = populatedArray(SIZE); |
347 |
> |
assertEquals(SIZE, full.size()); |
348 |
> |
assertEquals(0, empty.size()); |
349 |
|
} |
350 |
|
|
351 |
|
/** |
352 |
|
* toArray returns an Object array containing all elements from the list |
353 |
|
*/ |
354 |
|
public void testToArray() { |
355 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
356 |
< |
Object[] o = full.toArray(); |
357 |
< |
assertEquals(3, o.length); |
358 |
< |
assertEquals(0, ((Integer)o[0]).intValue()); |
359 |
< |
assertEquals(1, ((Integer)o[1]).intValue()); |
360 |
< |
assertEquals(2, ((Integer)o[2]).intValue()); |
355 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
356 |
> |
Object[] o = full.toArray(); |
357 |
> |
assertEquals(3, o.length); |
358 |
> |
assertEquals(0, ((Integer)o[0]).intValue()); |
359 |
> |
assertEquals(1, ((Integer)o[1]).intValue()); |
360 |
> |
assertEquals(2, ((Integer)o[2]).intValue()); |
361 |
|
} |
362 |
|
|
363 |
|
/** |
365 |
|
* the list |
366 |
|
*/ |
367 |
|
public void testToArray2() { |
368 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
369 |
< |
Integer[] i = new Integer[3]; |
370 |
< |
i = (Integer[])full.toArray(i); |
371 |
< |
assertEquals(3, i.length); |
372 |
< |
assertEquals(0, i[0].intValue()); |
373 |
< |
assertEquals(1, i[1].intValue()); |
374 |
< |
assertEquals(2, i[2].intValue()); |
368 |
> |
CopyOnWriteArrayList full = populatedArray(3); |
369 |
> |
Integer[] i = new Integer[3]; |
370 |
> |
i = (Integer[])full.toArray(i); |
371 |
> |
assertEquals(3, i.length); |
372 |
> |
assertEquals(0, i[0].intValue()); |
373 |
> |
assertEquals(1, i[1].intValue()); |
374 |
> |
assertEquals(2, i[2].intValue()); |
375 |
|
} |
376 |
|
|
377 |
|
|
379 |
|
* sublists contains elements at indexes offset from their base |
380 |
|
*/ |
381 |
|
public void testSubList() { |
382 |
< |
CopyOnWriteArrayList a = populatedArray(10); |
382 |
> |
CopyOnWriteArrayList a = populatedArray(10); |
383 |
|
assertTrue(a.subList(1,1).isEmpty()); |
384 |
< |
for(int j = 0; j < 9; ++j) { |
385 |
< |
for(int i = j ; i < 10; ++i) { |
386 |
< |
List b = a.subList(j,i); |
387 |
< |
for(int k = j; k < i; ++k) { |
388 |
< |
assertEquals(new Integer(k), b.get(k-j)); |
389 |
< |
} |
390 |
< |
} |
391 |
< |
} |
384 |
> |
for (int j = 0; j < 9; ++j) { |
385 |
> |
for (int i = j ; i < 10; ++i) { |
386 |
> |
List b = a.subList(j,i); |
387 |
> |
for (int k = j; k < i; ++k) { |
388 |
> |
assertEquals(new Integer(k), b.get(k-j)); |
389 |
> |
} |
390 |
> |
} |
391 |
> |
} |
392 |
|
|
393 |
< |
List s = a.subList(2, 5); |
393 |
> |
List s = a.subList(2, 5); |
394 |
|
assertEquals(s.size(), 3); |
395 |
|
s.set(2, m1); |
396 |
|
assertEquals(a.get(4), m1); |
397 |
< |
s.clear(); |
397 |
> |
s.clear(); |
398 |
|
assertEquals(a.size(), 7); |
399 |
|
} |
400 |
|
|
410 |
|
c.add("zfasdfsdf"); |
411 |
|
c.add("asdadasd"); |
412 |
|
c.toArray(new Long[5]); |
413 |
< |
shouldThrow(); |
414 |
< |
} catch(ArrayStoreException e){} |
413 |
> |
shouldThrow(); |
414 |
> |
} catch (ArrayStoreException e) {} |
415 |
|
} |
416 |
|
|
417 |
|
/** |
422 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
423 |
|
c.get(-1); |
424 |
|
shouldThrow(); |
425 |
< |
} catch(IndexOutOfBoundsException e){} |
425 |
> |
} catch (IndexOutOfBoundsException e) {} |
426 |
|
} |
427 |
|
|
428 |
|
/** |
435 |
|
c.add("asdad"); |
436 |
|
c.get(100); |
437 |
|
shouldThrow(); |
438 |
< |
} catch(IndexOutOfBoundsException e){} |
438 |
> |
} catch (IndexOutOfBoundsException e) {} |
439 |
|
} |
440 |
|
|
441 |
|
/** |
446 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
447 |
|
c.set(-1,"qwerty"); |
448 |
|
shouldThrow(); |
449 |
< |
} catch(IndexOutOfBoundsException e){} |
449 |
> |
} catch (IndexOutOfBoundsException e) {} |
450 |
|
} |
451 |
|
|
452 |
|
/** |
459 |
|
c.add("asdad"); |
460 |
|
c.set(100, "qwerty"); |
461 |
|
shouldThrow(); |
462 |
< |
} catch(IndexOutOfBoundsException e){} |
462 |
> |
} catch (IndexOutOfBoundsException e) {} |
463 |
|
} |
464 |
|
|
465 |
|
/** |
470 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
471 |
|
c.add(-1,"qwerty"); |
472 |
|
shouldThrow(); |
473 |
< |
} catch(IndexOutOfBoundsException e){} |
473 |
> |
} catch (IndexOutOfBoundsException e) {} |
474 |
|
} |
475 |
|
|
476 |
|
/** |
483 |
|
c.add("asdasdasd"); |
484 |
|
c.add(100, "qwerty"); |
485 |
|
shouldThrow(); |
486 |
< |
} catch(IndexOutOfBoundsException e){} |
486 |
> |
} catch (IndexOutOfBoundsException e) {} |
487 |
|
} |
488 |
|
|
489 |
|
/** |
494 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
495 |
|
c.remove(-1); |
496 |
|
shouldThrow(); |
497 |
< |
} catch(IndexOutOfBoundsException e){} |
497 |
> |
} catch (IndexOutOfBoundsException e) {} |
498 |
|
} |
499 |
|
|
500 |
|
/** |
507 |
|
c.add("adasdasd"); |
508 |
|
c.remove(100); |
509 |
|
shouldThrow(); |
510 |
< |
} catch(IndexOutOfBoundsException e){} |
510 |
> |
} catch (IndexOutOfBoundsException e) {} |
511 |
|
} |
512 |
|
|
513 |
|
/** |
518 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
519 |
|
c.addAll(-1,new LinkedList()); |
520 |
|
shouldThrow(); |
521 |
< |
} catch(IndexOutOfBoundsException e){} |
521 |
> |
} catch (IndexOutOfBoundsException e) {} |
522 |
|
} |
523 |
|
|
524 |
|
/** |
531 |
|
c.add("asdasdasd"); |
532 |
|
c.addAll(100, new LinkedList()); |
533 |
|
shouldThrow(); |
534 |
< |
} catch(IndexOutOfBoundsException e){} |
534 |
> |
} catch (IndexOutOfBoundsException e) {} |
535 |
|
} |
536 |
|
|
537 |
|
/** |
542 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
543 |
|
c.listIterator(-1); |
544 |
|
shouldThrow(); |
545 |
< |
} catch(IndexOutOfBoundsException e){} |
545 |
> |
} catch (IndexOutOfBoundsException e) {} |
546 |
|
} |
547 |
|
|
548 |
|
/** |
555 |
|
c.add("asdasdas"); |
556 |
|
c.listIterator(100); |
557 |
|
shouldThrow(); |
558 |
< |
} catch(IndexOutOfBoundsException e){} |
558 |
> |
} catch (IndexOutOfBoundsException e) {} |
559 |
|
} |
560 |
|
|
561 |
|
/** |
567 |
|
c.subList(-1,100); |
568 |
|
|
569 |
|
shouldThrow(); |
570 |
< |
} catch(IndexOutOfBoundsException e){} |
570 |
> |
} catch (IndexOutOfBoundsException e) {} |
571 |
|
} |
572 |
|
|
573 |
|
/** |
579 |
|
c.add("asdasd"); |
580 |
|
c.subList(1,100); |
581 |
|
shouldThrow(); |
582 |
< |
} catch(IndexOutOfBoundsException e){} |
582 |
> |
} catch (IndexOutOfBoundsException e) {} |
583 |
|
} |
584 |
|
|
585 |
|
/** |
592 |
|
c.subList(3,1); |
593 |
|
|
594 |
|
shouldThrow(); |
595 |
< |
} catch(IndexOutOfBoundsException e){} |
595 |
> |
} catch (IndexOutOfBoundsException e) {} |
596 |
|
} |
597 |
|
|
598 |
|
/** |
613 |
|
assertEquals(q.size(), r.size()); |
614 |
|
assertTrue(q.equals(r)); |
615 |
|
assertTrue(r.equals(q)); |
616 |
< |
} catch(Exception e){ |
616 |
> |
} catch (Exception e) { |
617 |
|
unexpectedException(); |
618 |
|
} |
619 |
|
} |