32 |
|
return q; |
33 |
|
} |
34 |
|
|
35 |
< |
public void testConstructor1(){ |
35 |
> |
/** |
36 |
> |
* new queue is empty |
37 |
> |
*/ |
38 |
> |
public void testConstructor1() { |
39 |
|
assertEquals(0, new LinkedList().size()); |
40 |
|
} |
41 |
|
|
42 |
+ |
/** |
43 |
+ |
* Initializing from null Collection throws NPE |
44 |
+ |
*/ |
45 |
|
public void testConstructor3() { |
46 |
|
try { |
47 |
|
LinkedList q = new LinkedList((Collection)null); |
48 |
< |
fail("Cannot make from null collection"); |
48 |
> |
shouldThrow(); |
49 |
|
} |
50 |
|
catch (NullPointerException success) {} |
51 |
|
} |
52 |
|
|
53 |
< |
public void testConstructor6(){ |
53 |
> |
/** |
54 |
> |
* Queue contains all elements of collection used to initialize |
55 |
> |
|
56 |
> |
*/ |
57 |
> |
public void testConstructor6() { |
58 |
|
try { |
59 |
|
Integer[] ints = new Integer[SIZE]; |
60 |
|
for (int i = 0; i < SIZE; ++i) |
66 |
|
finally {} |
67 |
|
} |
68 |
|
|
69 |
+ |
/** |
70 |
+ |
* isEmpty is true before add, false after |
71 |
+ |
*/ |
72 |
|
public void testEmpty() { |
73 |
|
LinkedList q = new LinkedList(); |
74 |
|
assertTrue(q.isEmpty()); |
80 |
|
assertTrue(q.isEmpty()); |
81 |
|
} |
82 |
|
|
83 |
+ |
/** |
84 |
+ |
* size changes when elements added and removed |
85 |
+ |
*/ |
86 |
|
public void testSize() { |
87 |
|
LinkedList q = populatedQueue(SIZE); |
88 |
|
for (int i = 0; i < SIZE; ++i) { |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
< |
public void testOfferNull(){ |
98 |
> |
/** |
99 |
> |
* offer(null) succeeds |
100 |
> |
*/ |
101 |
> |
public void testOfferNull() { |
102 |
|
try { |
103 |
|
LinkedList q = new LinkedList(); |
104 |
|
q.offer(null); |
105 |
|
} catch (NullPointerException ie) { |
106 |
< |
fail("should not throw NPE"); |
106 |
> |
unexpectedException(); |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
+ |
/** |
111 |
+ |
* Offer succeeds |
112 |
+ |
*/ |
113 |
|
public void testOffer() { |
114 |
|
LinkedList q = new LinkedList(); |
115 |
|
assertTrue(q.offer(new Integer(0))); |
116 |
|
assertTrue(q.offer(new Integer(1))); |
117 |
|
} |
118 |
|
|
119 |
< |
public void testAdd(){ |
119 |
> |
/** |
120 |
> |
* add succeeds |
121 |
> |
*/ |
122 |
> |
public void testAdd() { |
123 |
|
LinkedList q = new LinkedList(); |
124 |
|
for (int i = 0; i < SIZE; ++i) { |
125 |
|
assertEquals(i, q.size()); |
127 |
|
} |
128 |
|
} |
129 |
|
|
130 |
< |
public void testAddAll1(){ |
130 |
> |
/** |
131 |
> |
* addAll(null) throws NPE |
132 |
> |
*/ |
133 |
> |
public void testAddAll1() { |
134 |
|
try { |
135 |
|
LinkedList q = new LinkedList(); |
136 |
|
q.addAll(null); |
137 |
< |
fail("Cannot add null collection"); |
137 |
> |
shouldThrow(); |
138 |
|
} |
139 |
|
catch (NullPointerException success) {} |
140 |
|
} |
141 |
|
|
142 |
< |
public void testAddAll5(){ |
142 |
> |
/** |
143 |
> |
* Queue contains all elements, in traversal order, of successful addAll |
144 |
> |
*/ |
145 |
> |
public void testAddAll5() { |
146 |
|
try { |
147 |
|
Integer[] empty = new Integer[0]; |
148 |
|
Integer[] ints = new Integer[SIZE]; |
157 |
|
finally {} |
158 |
|
} |
159 |
|
|
160 |
< |
public void testPoll(){ |
160 |
> |
/** |
161 |
> |
* addAll with too large an index throws IOOBE |
162 |
> |
*/ |
163 |
> |
public void testAddAll2_IndexOutOfBoundsException() { |
164 |
> |
try { |
165 |
> |
LinkedList l = new LinkedList(); |
166 |
> |
l.add(new Object()); |
167 |
> |
LinkedList m = new LinkedList(); |
168 |
> |
m.add(new Object()); |
169 |
> |
l.addAll(4,m); |
170 |
> |
shouldThrow(); |
171 |
> |
} catch(IndexOutOfBoundsException success) {} |
172 |
> |
} |
173 |
> |
|
174 |
> |
/** |
175 |
> |
* addAll with negative index throws IOOBE |
176 |
> |
*/ |
177 |
> |
public void testAddAll4_BadIndex() { |
178 |
> |
try { |
179 |
> |
LinkedList l = new LinkedList(); |
180 |
> |
l.add(new Object()); |
181 |
> |
LinkedList m = new LinkedList(); |
182 |
> |
m.add(new Object()); |
183 |
> |
l.addAll(-1,m); |
184 |
> |
shouldThrow(); |
185 |
> |
} catch(IndexOutOfBoundsException success){} |
186 |
> |
} |
187 |
> |
|
188 |
> |
/** |
189 |
> |
* poll succeeds unless empty |
190 |
> |
*/ |
191 |
> |
public void testPoll() { |
192 |
|
LinkedList q = populatedQueue(SIZE); |
193 |
|
for (int i = 0; i < SIZE; ++i) { |
194 |
|
assertEquals(i, ((Integer)q.poll()).intValue()); |
196 |
|
assertNull(q.poll()); |
197 |
|
} |
198 |
|
|
199 |
< |
public void testPeek(){ |
199 |
> |
/** |
200 |
> |
* peek returns next element, or null if empty |
201 |
> |
*/ |
202 |
> |
public void testPeek() { |
203 |
|
LinkedList q = populatedQueue(SIZE); |
204 |
|
for (int i = 0; i < SIZE; ++i) { |
205 |
|
assertEquals(i, ((Integer)q.peek()).intValue()); |
210 |
|
assertNull(q.peek()); |
211 |
|
} |
212 |
|
|
213 |
< |
public void testElement(){ |
213 |
> |
/** |
214 |
> |
* |
215 |
> |
*/ |
216 |
> |
public void testElement() { |
217 |
|
LinkedList q = populatedQueue(SIZE); |
218 |
|
for (int i = 0; i < SIZE; ++i) { |
219 |
|
assertEquals(i, ((Integer)q.element()).intValue()); |
221 |
|
} |
222 |
|
try { |
223 |
|
q.element(); |
224 |
< |
fail("no such element"); |
224 |
> |
shouldThrow(); |
225 |
|
} |
226 |
|
catch (NoSuchElementException success) {} |
227 |
|
} |
228 |
|
|
229 |
< |
public void testRemove(){ |
229 |
> |
/** |
230 |
> |
* element returns next element, or throws NSEE if empty |
231 |
> |
*/ |
232 |
> |
public void testRemove() { |
233 |
|
LinkedList q = populatedQueue(SIZE); |
234 |
|
for (int i = 0; i < SIZE; ++i) { |
235 |
|
assertEquals(i, ((Integer)q.remove()).intValue()); |
236 |
|
} |
237 |
|
try { |
238 |
|
q.remove(); |
239 |
< |
fail("remove should throw"); |
239 |
> |
shouldThrow(); |
240 |
|
} catch (NoSuchElementException success){ |
241 |
|
} |
242 |
|
} |
243 |
|
|
244 |
< |
public void testRemoveElement(){ |
244 |
> |
/** |
245 |
> |
* remove(x) removes x and returns true if present |
246 |
> |
*/ |
247 |
> |
public void testRemoveElement() { |
248 |
|
LinkedList q = populatedQueue(SIZE); |
249 |
|
for (int i = 1; i < SIZE; i+=2) { |
250 |
|
assertTrue(q.remove(new Integer(i))); |
256 |
|
assertTrue(q.isEmpty()); |
257 |
|
} |
258 |
|
|
259 |
< |
public void testContains(){ |
259 |
> |
/** |
260 |
> |
* contains(x) reports true when elements added but not yet removed |
261 |
> |
*/ |
262 |
> |
public void testContains() { |
263 |
|
LinkedList q = populatedQueue(SIZE); |
264 |
|
for (int i = 0; i < SIZE; ++i) { |
265 |
|
assertTrue(q.contains(new Integer(i))); |
268 |
|
} |
269 |
|
} |
270 |
|
|
271 |
< |
public void testClear(){ |
271 |
> |
/** |
272 |
> |
* clear removes all elements |
273 |
> |
*/ |
274 |
> |
public void testClear() { |
275 |
|
LinkedList q = populatedQueue(SIZE); |
276 |
|
q.clear(); |
277 |
|
assertTrue(q.isEmpty()); |
282 |
|
assertTrue(q.isEmpty()); |
283 |
|
} |
284 |
|
|
285 |
< |
public void testContainsAll(){ |
285 |
> |
/** |
286 |
> |
* containsAll(c) is true when c contains a subset of elements |
287 |
> |
*/ |
288 |
> |
public void testContainsAll() { |
289 |
|
LinkedList q = populatedQueue(SIZE); |
290 |
|
LinkedList p = new LinkedList(); |
291 |
|
for (int i = 0; i < SIZE; ++i) { |
296 |
|
assertTrue(p.containsAll(q)); |
297 |
|
} |
298 |
|
|
299 |
< |
public void testRetainAll(){ |
299 |
> |
/** |
300 |
> |
* retainAll(c) retains only those elements of c and reports true if changed |
301 |
> |
*/ |
302 |
> |
public void testRetainAll() { |
303 |
|
LinkedList q = populatedQueue(SIZE); |
304 |
|
LinkedList p = populatedQueue(SIZE); |
305 |
|
for (int i = 0; i < SIZE; ++i) { |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
< |
public void testRemoveAll(){ |
318 |
> |
/** |
319 |
> |
* removeAll(c) removes only those elements of c and reports true if changed |
320 |
> |
*/ |
321 |
> |
public void testRemoveAll() { |
322 |
|
for (int i = 1; i < SIZE; ++i) { |
323 |
|
LinkedList q = populatedQueue(SIZE); |
324 |
|
LinkedList p = populatedQueue(i); |
331 |
|
} |
332 |
|
} |
333 |
|
|
334 |
< |
public void testToArray(){ |
334 |
> |
/** |
335 |
> |
* toArray contains all elements |
336 |
> |
*/ |
337 |
> |
public void testToArray() { |
338 |
|
LinkedList q = populatedQueue(SIZE); |
339 |
|
Object[] o = q.toArray(); |
340 |
|
Arrays.sort(o); |
342 |
|
assertEquals(o[i], q.poll()); |
343 |
|
} |
344 |
|
|
345 |
< |
public void testToArray2(){ |
345 |
> |
/** |
346 |
> |
* toArray(a) contains all elements |
347 |
> |
*/ |
348 |
> |
public void testToArray2() { |
349 |
|
LinkedList q = populatedQueue(SIZE); |
350 |
|
Integer[] ints = new Integer[SIZE]; |
351 |
|
ints = (Integer[])q.toArray(ints); |
353 |
|
for(int i = 0; i < ints.length; i++) |
354 |
|
assertEquals(ints[i], q.poll()); |
355 |
|
} |
356 |
+ |
|
357 |
+ |
/** |
358 |
+ |
* toArray(null) throws NPE |
359 |
+ |
*/ |
360 |
+ |
public void testToArray_BadArg() { |
361 |
+ |
try { |
362 |
+ |
LinkedList l = new LinkedList(); |
363 |
+ |
l.add(new Object()); |
364 |
+ |
Object o[] = l.toArray(null); |
365 |
+ |
shouldThrow(); |
366 |
+ |
} catch(NullPointerException success){} |
367 |
+ |
} |
368 |
+ |
|
369 |
+ |
/** |
370 |
+ |
* toArray with incompatable aray type throws CCE |
371 |
+ |
*/ |
372 |
+ |
public void testToArray1_BadArg() { |
373 |
+ |
try { |
374 |
+ |
LinkedList l = new LinkedList(); |
375 |
+ |
l.add(new Integer(5)); |
376 |
+ |
Object o[] = l.toArray(new String[10] ); |
377 |
+ |
shouldThrow(); |
378 |
+ |
} catch(ArrayStoreException success){} |
379 |
+ |
} |
380 |
|
|
381 |
< |
public void testIterator(){ |
381 |
> |
/** |
382 |
> |
* iterator iterates through all elements |
383 |
> |
*/ |
384 |
> |
public void testIterator() { |
385 |
|
LinkedList q = populatedQueue(SIZE); |
386 |
|
int i = 0; |
387 |
|
Iterator it = q.iterator(); |
392 |
|
assertEquals(i, SIZE); |
393 |
|
} |
394 |
|
|
395 |
+ |
/** |
396 |
+ |
* iterator ordering is FIFO |
397 |
+ |
*/ |
398 |
|
public void testIteratorOrdering() { |
274 |
– |
|
399 |
|
final LinkedList q = new LinkedList(); |
276 |
– |
|
400 |
|
q.add(new Integer(1)); |
401 |
|
q.add(new Integer(2)); |
402 |
|
q.add(new Integer(3)); |
280 |
– |
|
403 |
|
int k = 0; |
404 |
|
for (Iterator it = q.iterator(); it.hasNext();) { |
405 |
|
int i = ((Integer)(it.next())).intValue(); |
406 |
< |
assertEquals("items should come out in order", ++k, i); |
406 |
> |
assertEquals(++k, i); |
407 |
|
} |
408 |
|
|
409 |
< |
assertEquals("should go through 3 elements", 3, k); |
409 |
> |
assertEquals(3, k); |
410 |
|
} |
411 |
|
|
412 |
+ |
/** |
413 |
+ |
* iterator.remove removes current element |
414 |
+ |
*/ |
415 |
|
public void testIteratorRemove () { |
416 |
|
final LinkedList q = new LinkedList(); |
292 |
– |
|
417 |
|
q.add(new Integer(1)); |
418 |
|
q.add(new Integer(2)); |
419 |
|
q.add(new Integer(3)); |
296 |
– |
|
420 |
|
Iterator it = q.iterator(); |
421 |
|
it.next(); |
422 |
|
it.remove(); |
300 |
– |
|
423 |
|
it = q.iterator(); |
424 |
|
assertEquals(it.next(), new Integer(2)); |
425 |
|
assertEquals(it.next(), new Integer(3)); |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
< |
public void testToString(){ |
430 |
> |
/** |
431 |
> |
* toString contains toStrings of elements |
432 |
> |
*/ |
433 |
> |
public void testToString() { |
434 |
|
LinkedList q = populatedQueue(SIZE); |
435 |
|
String s = q.toString(); |
436 |
|
for (int i = 0; i < SIZE; ++i) { |
438 |
|
} |
439 |
|
} |
440 |
|
|
441 |
< |
public void testAddFirst(){ |
441 |
> |
/** |
442 |
> |
* peek returns element inserted with addFirst |
443 |
> |
*/ |
444 |
> |
public void testAddFirst() { |
445 |
|
LinkedList q = populatedQueue(3); |
446 |
< |
q.addFirst(new Integer(4)); |
447 |
< |
assertEquals(new Integer(4),q.get(0)); |
446 |
> |
q.addFirst(four); |
447 |
> |
assertEquals(four,q.peek()); |
448 |
|
} |
449 |
|
|
322 |
– |
public void testAddLast(){ |
323 |
– |
LinkedList q = populatedQueue(3); |
324 |
– |
q.addLast(new Integer(3)); |
325 |
– |
assertEquals(new Integer(3),q.get(3)); |
326 |
– |
} |
327 |
– |
|
328 |
– |
public void testGetFirst() { |
329 |
– |
LinkedList q = populatedQueue(3); |
330 |
– |
assertEquals(new Integer(0),q.getFirst()); |
331 |
– |
} |
332 |
– |
|
333 |
– |
public void testGetLast() { |
334 |
– |
LinkedList q = populatedQueue(3); |
335 |
– |
assertEquals(new Integer(2),q.getLast()); |
336 |
– |
} |
337 |
– |
|
338 |
– |
public void testIndexOf(){ |
339 |
– |
LinkedList q = populatedQueue(3); |
340 |
– |
assertEquals(0,q.indexOf(new Integer(0))); |
341 |
– |
assertEquals(1,q.indexOf(new Integer(1))); |
342 |
– |
assertEquals(2,q.indexOf(new Integer(2))); |
343 |
– |
assertEquals(-1, q.indexOf("not there")); |
344 |
– |
} |
345 |
– |
|
346 |
– |
public void testLastIndexOf(){ |
347 |
– |
LinkedList q = populatedQueue(3); |
348 |
– |
q.add(new Integer(2)); |
349 |
– |
assertEquals(3,q.lastIndexOf(new Integer(2))); |
350 |
– |
assertEquals(-1, q.lastIndexOf("not there")); |
351 |
– |
} |
352 |
– |
|
353 |
– |
public void testSet(){ |
354 |
– |
LinkedList q = populatedQueue(3); |
355 |
– |
q.set(0,(new Integer(1))); |
356 |
– |
assertFalse(q.contains(new Integer(0))); |
357 |
– |
assertEquals(new Integer(1), q.get(0)); |
358 |
– |
} |
359 |
– |
|
360 |
– |
|
361 |
– |
public void testGetFirst_NoSuchElementException(){ |
362 |
– |
try { |
363 |
– |
LinkedList l = new LinkedList(); |
364 |
– |
l.getFirst(); |
365 |
– |
fail("First Element"); |
366 |
– |
} |
367 |
– |
catch(NoSuchElementException success) {} |
368 |
– |
} |
369 |
– |
|
370 |
– |
public void testRemoveFirst() { |
371 |
– |
try { |
372 |
– |
LinkedList l = new LinkedList(); |
373 |
– |
l.removeFirst(); |
374 |
– |
fail("R: First Element"); |
375 |
– |
} |
376 |
– |
catch(NoSuchElementException success) {} |
377 |
– |
} |
378 |
– |
|
379 |
– |
public void testRemoveLast() { |
380 |
– |
try { |
381 |
– |
LinkedList l = new LinkedList(); |
382 |
– |
l.removeLast(); |
383 |
– |
fail("R: Last Element"); |
384 |
– |
} |
385 |
– |
catch(NoSuchElementException success) {} |
386 |
– |
} |
387 |
– |
|
388 |
– |
public void testGetLast_NoSuchElementException(){ |
389 |
– |
try { |
390 |
– |
LinkedList l = new LinkedList(); |
391 |
– |
l.getLast(); |
392 |
– |
fail("Last Element"); |
393 |
– |
} |
394 |
– |
catch(NoSuchElementException success) {} |
395 |
– |
} |
396 |
– |
|
397 |
– |
|
398 |
– |
public void testAddAll_NullPointerException(){ |
399 |
– |
try { |
400 |
– |
LinkedList l = new LinkedList(); |
401 |
– |
l.addAll((Collection)null); |
402 |
– |
fail("Add All Failed"); |
403 |
– |
} |
404 |
– |
catch(NullPointerException success){} |
405 |
– |
} |
406 |
– |
|
407 |
– |
|
408 |
– |
public void testAddAll1_OutOfBounds() { |
409 |
– |
try { |
410 |
– |
LinkedList l = new LinkedList(); |
411 |
– |
l.addAll(4,new LinkedList()); |
412 |
– |
fail("boolean addAll(int, Collection) should throw IndexOutOfBoundsException"); |
413 |
– |
} |
414 |
– |
catch(IndexOutOfBoundsException success) {} |
415 |
– |
} |
416 |
– |
|
417 |
– |
|
418 |
– |
public void testAddAll2_IndexOutOfBoundsException() { |
419 |
– |
try { |
420 |
– |
LinkedList l = new LinkedList(); |
421 |
– |
l.add(new Object()); |
422 |
– |
LinkedList m = new LinkedList(); |
423 |
– |
m.add(new Object()); |
424 |
– |
l.addAll(4,m); |
425 |
– |
fail("Add All Failed " + l.size()); |
426 |
– |
}catch(IndexOutOfBoundsException success) {} |
427 |
– |
} |
428 |
– |
|
429 |
– |
public void testAddAll4_BadIndex() { |
430 |
– |
try { |
431 |
– |
LinkedList l = new LinkedList(); |
432 |
– |
l.add(new Object()); |
433 |
– |
LinkedList m = new LinkedList(); |
434 |
– |
m.add(new Object()); |
435 |
– |
l.addAll(-1,m); |
436 |
– |
fail("Add All Failed " + l.size()); |
437 |
– |
}catch(IndexOutOfBoundsException success){} |
438 |
– |
} |
439 |
– |
|
440 |
– |
public void testget1() { |
441 |
– |
try { |
442 |
– |
LinkedList l = new LinkedList(); |
443 |
– |
l.add(new Object()); |
444 |
– |
l.get(-1); |
445 |
– |
fail("get Failed - l.get(-1)"); |
446 |
– |
}catch(IndexOutOfBoundsException success) {} |
447 |
– |
} |
448 |
– |
|
449 |
– |
public void testget2() { |
450 |
– |
try { |
451 |
– |
LinkedList l = new LinkedList(); |
452 |
– |
l.add(new Object()); |
453 |
– |
l.get(5); |
454 |
– |
fail("get Failed - l.get(5) l.size(): " + l.size()); |
455 |
– |
}catch(IndexOutOfBoundsException success){} |
456 |
– |
} |
457 |
– |
|
458 |
– |
public void testset1() { |
459 |
– |
try { |
460 |
– |
LinkedList l = new LinkedList(); |
461 |
– |
l.add(new Object()); |
462 |
– |
l.set(-1,new Object()); |
463 |
– |
fail("set failed - l.set(-1,...)" + l.size()); |
464 |
– |
}catch(IndexOutOfBoundsException success){} |
465 |
– |
} |
466 |
– |
|
467 |
– |
public void testset2() { |
468 |
– |
try { |
469 |
– |
LinkedList l = new LinkedList(); |
470 |
– |
l.add(new Object()); |
471 |
– |
l.set(5,new Object()); |
472 |
– |
fail("set failed = l.set(5,..) l.size():" + l.size()); |
473 |
– |
}catch(IndexOutOfBoundsException success){} |
474 |
– |
} |
475 |
– |
|
476 |
– |
public void testadd1() { |
477 |
– |
try { |
478 |
– |
LinkedList l = new LinkedList(); |
479 |
– |
l.add(new Object()); |
480 |
– |
l.add(-1,new Object()); |
481 |
– |
fail("Add Failed - l.add(-1) l.size(): " + l.size()); |
482 |
– |
}catch(IndexOutOfBoundsException success){} |
483 |
– |
} |
484 |
– |
|
485 |
– |
public void add2(){ |
486 |
– |
try { |
487 |
– |
LinkedList l = new LinkedList(); |
488 |
– |
l.add(new Object()); |
489 |
– |
l.add(5,new Object()); |
490 |
– |
fail("Add Failed l.add(f,...)"); |
491 |
– |
}catch(IndexOutOfBoundsException success) {} |
492 |
– |
} |
493 |
– |
|
494 |
– |
public void testremove(){ |
495 |
– |
try { |
496 |
– |
LinkedList l = new LinkedList(); |
497 |
– |
l.add(new Object()); |
498 |
– |
l.remove(-1); |
499 |
– |
fail("Remove Failed l.remove(-1); l.size():" + l.size()); |
500 |
– |
}catch(IndexOutOfBoundsException success){} |
501 |
– |
} |
502 |
– |
|
503 |
– |
public void testremove1(){ |
504 |
– |
try { |
505 |
– |
LinkedList l = new LinkedList(); |
506 |
– |
l.add(new Object()); |
507 |
– |
l.remove(5); |
508 |
– |
fail("Remove Failed l.remove(5); l.size():" + l.size()); |
509 |
– |
}catch(IndexOutOfBoundsException success){} |
510 |
– |
} |
511 |
– |
|
512 |
– |
|
513 |
– |
public void testremove2(){ |
514 |
– |
try{ |
515 |
– |
LinkedList l = new LinkedList(); |
516 |
– |
l.remove(); |
517 |
– |
fail("LinkedList - Object remove() should throw a NoSuchElementException"); |
518 |
– |
}catch(NoSuchElementException e){} |
519 |
– |
} |
520 |
– |
|
521 |
– |
public void testlistIt1() { |
522 |
– |
try { |
523 |
– |
LinkedList l = new LinkedList(); |
524 |
– |
l.add(new Object()); |
525 |
– |
l.listIterator(5); |
526 |
– |
fail("l.listIterator(5) l.size():" + l.size()); |
527 |
– |
}catch(IndexOutOfBoundsException success){} |
528 |
– |
} |
529 |
– |
|
530 |
– |
public void testlistIt2() { |
531 |
– |
try { |
532 |
– |
LinkedList l = new LinkedList(); |
533 |
– |
l.add(new Object()); |
534 |
– |
l.listIterator(-1); |
535 |
– |
fail("l.listIterator(-1) l.size():" + l.size()); |
536 |
– |
}catch(IndexOutOfBoundsException success){} |
537 |
– |
} |
538 |
– |
|
539 |
– |
public void testlistIt3() { |
540 |
– |
try { |
541 |
– |
LinkedList l = new LinkedList(); |
542 |
– |
l.add(new Object()); |
543 |
– |
ListIterator a = l.listIterator(0); |
544 |
– |
l.removeFirst(); |
545 |
– |
a.next(); |
546 |
– |
fail("l.listIterator(-1) l.size():" + l.size()); |
547 |
– |
}catch(ConcurrentModificationException success){} |
548 |
– |
} |
549 |
– |
|
550 |
– |
public void testToArray_BadArg() { |
551 |
– |
try { |
552 |
– |
LinkedList l = new LinkedList(); |
553 |
– |
l.add(new Object()); |
554 |
– |
Object o[] = l.toArray(null); |
555 |
– |
fail("l.toArray(null) did not throw an exception"); |
556 |
– |
}catch(NullPointerException success){} |
557 |
– |
} |
558 |
– |
|
559 |
– |
public void testToArray1_BadArg() { |
560 |
– |
try { |
561 |
– |
LinkedList l = new LinkedList(); |
562 |
– |
l.add(new Integer(5)); |
563 |
– |
Object o[] = l.toArray(new String[10] ); |
564 |
– |
fail("l.toArray(String[] f) did not throw an exception, an Integer was added"); |
565 |
– |
}catch(ArrayStoreException success){} |
566 |
– |
} |
567 |
– |
|
450 |
|
} |