ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/LinkedListTest.java
(Generate patch)

Comparing jsr166/src/test/tck/LinkedListTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:55 2003 UTC vs.
Revision 1.4 by dl, Sat Sep 20 18:20:08 2003 UTC

# Line 9 | Line 9 | import junit.framework.*;
9   import java.util.*;
10   import java.util.concurrent.*;
11  
12 < public class LinkedListTest extends TestCase {
13 <
14 <    private static final int N = 10;
15 <    private static final long SHORT_DELAY_MS = 100;
16 <    private static final long MEDIUM_DELAY_MS = 1000;
17 <    private static final long LONG_DELAY_MS = 10000;
18 <
12 > public class LinkedListTest extends JSR166TestCase {
13      public static void main(String[] args) {
14          junit.textui.TestRunner.run (suite());  
15      }
# Line 28 | Line 22 | public class LinkedListTest extends Test
22       * Create a queue of given size containing consecutive
23       * Integers 0 ... n.
24       */
25 <    private LinkedList fullQueue(int n) {
25 >    private LinkedList populatedQueue(int n) {
26          LinkedList q = new LinkedList();
27          assertTrue(q.isEmpty());
28          for(int i = 0; i < n; ++i)
# Line 38 | Line 32 | public class LinkedListTest extends Test
32          return q;
33      }
34  
35 <    public void testConstructor1(){
35 >    /**
36 >     *
37 >     */
38 >    public void testConstructor1() {
39          assertEquals(0, new LinkedList().size());
40      }
41  
42 +    /**
43 +     *
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 >     *
55 >     */
56 >    public void testConstructor6() {
57          try {
58 <            Integer[] ints = new Integer[N];
59 <            for (int i = 0; i < N; ++i)
58 >            Integer[] ints = new Integer[SIZE];
59 >            for (int i = 0; i < SIZE; ++i)
60                  ints[i] = new Integer(i);
61              LinkedList q = new LinkedList(Arrays.asList(ints));
62 <            for (int i = 0; i < N; ++i)
62 >            for (int i = 0; i < SIZE; ++i)
63                  assertEquals(ints[i], q.poll());
64          }
65          finally {}
66      }
67  
68 +    /**
69 +     *
70 +     */
71      public void testEmpty() {
72          LinkedList q = new LinkedList();
73          assertTrue(q.isEmpty());
# Line 73 | Line 79 | public class LinkedListTest extends Test
79          assertTrue(q.isEmpty());
80      }
81  
82 +    /**
83 +     *
84 +     */
85      public void testSize() {
86 <        LinkedList q = fullQueue(N);
87 <        for (int i = 0; i < N; ++i) {
88 <            assertEquals(N-i, q.size());
86 >        LinkedList q = populatedQueue(SIZE);
87 >        for (int i = 0; i < SIZE; ++i) {
88 >            assertEquals(SIZE-i, q.size());
89              q.remove();
90          }
91 <        for (int i = 0; i < N; ++i) {
91 >        for (int i = 0; i < SIZE; ++i) {
92              assertEquals(i, q.size());
93              q.add(new Integer(i));
94          }
95      }
96  
97 <    public void testOfferNull(){
97 >    /**
98 >     *
99 >     */
100 >    public void testOfferNull() {
101          try {
102              LinkedList q = new LinkedList();
103              q.offer(null);
104          } catch (NullPointerException ie) {
105 <            fail("should not throw NPE");
105 >            unexpectedException();
106          }  
107      }
108  
109 +    /**
110 +     *
111 +     */
112      public void testOffer() {
113          LinkedList q = new LinkedList();
114          assertTrue(q.offer(new Integer(0)));
115          assertTrue(q.offer(new Integer(1)));
116      }
117  
118 <    public void testAdd(){
118 >    /**
119 >     *
120 >     */
121 >    public void testAdd() {
122          LinkedList q = new LinkedList();
123 <        for (int i = 0; i < N; ++i) {
123 >        for (int i = 0; i < SIZE; ++i) {
124              assertEquals(i, q.size());
125              assertTrue(q.add(new Integer(i)));
126          }
127      }
128  
129 <    public void testAddAll1(){
129 >    /**
130 >     *
131 >     */
132 >    public void testAddAll1() {
133          try {
134              LinkedList q = new LinkedList();
135              q.addAll(null);
136 <            fail("Cannot add null collection");
136 >            shouldThrow();
137          }
138          catch (NullPointerException success) {}
139      }
140  
141 <    public void testAddAll5(){
141 >    /**
142 >     *
143 >     */
144 >    public void testAddAll5() {
145          try {
146              Integer[] empty = new Integer[0];
147 <            Integer[] ints = new Integer[N];
148 <            for (int i = 0; i < N; ++i)
147 >            Integer[] ints = new Integer[SIZE];
148 >            for (int i = 0; i < SIZE; ++i)
149                  ints[i] = new Integer(i);
150              LinkedList q = new LinkedList();
151              assertFalse(q.addAll(Arrays.asList(empty)));
152              assertTrue(q.addAll(Arrays.asList(ints)));
153 <            for (int i = 0; i < N; ++i)
153 >            for (int i = 0; i < SIZE; ++i)
154                  assertEquals(ints[i], q.poll());
155          }
156          finally {}
157      }
158  
159 <    public void testPoll(){
160 <        LinkedList q = fullQueue(N);
161 <        for (int i = 0; i < N; ++i) {
159 >    /**
160 >     *
161 >     */
162 >    public void testPoll() {
163 >        LinkedList q = populatedQueue(SIZE);
164 >        for (int i = 0; i < SIZE; ++i) {
165              assertEquals(i, ((Integer)q.poll()).intValue());
166          }
167          assertNull(q.poll());
168      }
169  
170 <    public void testPeek(){
171 <        LinkedList q = fullQueue(N);
172 <        for (int i = 0; i < N; ++i) {
170 >    /**
171 >     *
172 >     */
173 >    public void testPeek() {
174 >        LinkedList q = populatedQueue(SIZE);
175 >        for (int i = 0; i < SIZE; ++i) {
176              assertEquals(i, ((Integer)q.peek()).intValue());
177              q.poll();
178              assertTrue(q.peek() == null ||
# Line 151 | Line 181 | public class LinkedListTest extends Test
181          assertNull(q.peek());
182      }
183  
184 <    public void testElement(){
185 <        LinkedList q = fullQueue(N);
186 <        for (int i = 0; i < N; ++i) {
184 >    /**
185 >     *
186 >     */
187 >    public void testElement() {
188 >        LinkedList q = populatedQueue(SIZE);
189 >        for (int i = 0; i < SIZE; ++i) {
190              assertEquals(i, ((Integer)q.element()).intValue());
191              q.poll();
192          }
193          try {
194              q.element();
195 <            fail("no such element");
195 >            shouldThrow();
196          }
197          catch (NoSuchElementException success) {}
198      }
199  
200 <    public void testRemove(){
201 <        LinkedList q = fullQueue(N);
202 <        for (int i = 0; i < N; ++i) {
200 >    /**
201 >     *
202 >     */
203 >    public void testRemove() {
204 >        LinkedList q = populatedQueue(SIZE);
205 >        for (int i = 0; i < SIZE; ++i) {
206              assertEquals(i, ((Integer)q.remove()).intValue());
207          }
208          try {
209              q.remove();
210 <            fail("remove should throw");
210 >            shouldThrow();
211          } catch (NoSuchElementException success){
212          }  
213      }
214  
215 <    public void testRemoveElement(){
216 <        LinkedList q = fullQueue(N);
217 <        for (int i = 1; i < N; i+=2) {
215 >    /**
216 >     *
217 >     */
218 >    public void testRemoveElement() {
219 >        LinkedList q = populatedQueue(SIZE);
220 >        for (int i = 1; i < SIZE; i+=2) {
221              assertTrue(q.remove(new Integer(i)));
222          }
223 <        for (int i = 0; i < N; i+=2) {
223 >        for (int i = 0; i < SIZE; i+=2) {
224              assertTrue(q.remove(new Integer(i)));
225              assertFalse(q.remove(new Integer(i+1)));
226          }
227 <        assert(q.isEmpty());
227 >        assertTrue(q.isEmpty());
228      }
229          
230 <    public void testContains(){
231 <        LinkedList q = fullQueue(N);
232 <        for (int i = 0; i < N; ++i) {
230 >    /**
231 >     *
232 >     */
233 >    public void testContains() {
234 >        LinkedList q = populatedQueue(SIZE);
235 >        for (int i = 0; i < SIZE; ++i) {
236              assertTrue(q.contains(new Integer(i)));
237              q.poll();
238              assertFalse(q.contains(new Integer(i)));
239          }
240      }
241  
242 <    public void testClear(){
243 <        LinkedList q = fullQueue(N);
242 >    /**
243 >     *
244 >     */
245 >    public void testClear() {
246 >        LinkedList q = populatedQueue(SIZE);
247          q.clear();
248          assertTrue(q.isEmpty());
249          assertEquals(0, q.size());
# Line 208 | Line 253 | public class LinkedListTest extends Test
253          assertTrue(q.isEmpty());
254      }
255  
256 <    public void testContainsAll(){
257 <        LinkedList q = fullQueue(N);
256 >    /**
257 >     *
258 >     */
259 >    public void testContainsAll() {
260 >        LinkedList q = populatedQueue(SIZE);
261          LinkedList p = new LinkedList();
262 <        for (int i = 0; i < N; ++i) {
262 >        for (int i = 0; i < SIZE; ++i) {
263              assertTrue(q.containsAll(p));
264              assertFalse(p.containsAll(q));
265              p.add(new Integer(i));
# Line 219 | Line 267 | public class LinkedListTest extends Test
267          assertTrue(p.containsAll(q));
268      }
269  
270 <    public void testRetainAll(){
271 <        LinkedList q = fullQueue(N);
272 <        LinkedList p = fullQueue(N);
273 <        for (int i = 0; i < N; ++i) {
270 >    /**
271 >     *
272 >     */
273 >    public void testRetainAll() {
274 >        LinkedList q = populatedQueue(SIZE);
275 >        LinkedList p = populatedQueue(SIZE);
276 >        for (int i = 0; i < SIZE; ++i) {
277              boolean changed = q.retainAll(p);
278              if (i == 0)
279                  assertFalse(changed);
# Line 230 | Line 281 | public class LinkedListTest extends Test
281                  assertTrue(changed);
282  
283              assertTrue(q.containsAll(p));
284 <            assertEquals(N-i, q.size());
284 >            assertEquals(SIZE-i, q.size());
285              p.remove();
286          }
287      }
288  
289 <    public void testRemoveAll(){
290 <        for (int i = 1; i < N; ++i) {
291 <            LinkedList q = fullQueue(N);
292 <            LinkedList p = fullQueue(i);
289 >    /**
290 >     *
291 >     */
292 >    public void testRemoveAll() {
293 >        for (int i = 1; i < SIZE; ++i) {
294 >            LinkedList q = populatedQueue(SIZE);
295 >            LinkedList p = populatedQueue(i);
296              assertTrue(q.removeAll(p));
297 <            assertEquals(N-i, q.size());
297 >            assertEquals(SIZE-i, q.size());
298              for (int j = 0; j < i; ++j) {
299                  Integer I = (Integer)(p.remove());
300                  assertFalse(q.contains(I));
# Line 248 | Line 302 | public class LinkedListTest extends Test
302          }
303      }
304  
305 <    public void testToArray(){
306 <        LinkedList q = fullQueue(N);
305 >    /**
306 >     *
307 >     */
308 >    public void testToArray() {
309 >        LinkedList q = populatedQueue(SIZE);
310          Object[] o = q.toArray();
311          Arrays.sort(o);
312          for(int i = 0; i < o.length; i++)
313              assertEquals(o[i], q.poll());
314      }
315  
316 <    public void testToArray2(){
317 <        LinkedList q = fullQueue(N);
318 <        Integer[] ints = new Integer[N];
316 >    /**
317 >     *
318 >     */
319 >    public void testToArray2() {
320 >        LinkedList q = populatedQueue(SIZE);
321 >        Integer[] ints = new Integer[SIZE];
322          ints = (Integer[])q.toArray(ints);
323          Arrays.sort(ints);
324          for(int i = 0; i < ints.length; i++)
325              assertEquals(ints[i], q.poll());
326      }
327      
328 <    public void testIterator(){
329 <        LinkedList q = fullQueue(N);
328 >    /**
329 >     *
330 >     */
331 >    public void testIterator() {
332 >        LinkedList q = populatedQueue(SIZE);
333          int i = 0;
334          Iterator it = q.iterator();
335          while(it.hasNext()) {
336              assertTrue(q.contains(it.next()));
337              ++i;
338          }
339 <        assertEquals(i, N);
339 >        assertEquals(i, SIZE);
340      }
341  
342 +    /**
343 +     *
344 +     */
345      public void testIteratorOrdering() {
346  
347          final LinkedList q = new LinkedList();
# Line 287 | Line 353 | public class LinkedListTest extends Test
353          int k = 0;
354          for (Iterator it = q.iterator(); it.hasNext();) {
355              int i = ((Integer)(it.next())).intValue();
356 <            assertEquals("items should come out in order", ++k, i);
356 >            assertEquals(++k, i);
357          }
358  
359 <        assertEquals("should go through 3 elements", 3, k);
359 >        assertEquals(3, k);
360      }
361  
362 +    /**
363 +     *
364 +     */
365      public void testIteratorRemove () {
366          final LinkedList q = new LinkedList();
367  
# Line 311 | Line 380 | public class LinkedListTest extends Test
380      }
381  
382  
383 <    public void testToString(){
384 <        LinkedList q = fullQueue(N);
383 >    /**
384 >     *
385 >     */
386 >    public void testToString() {
387 >        LinkedList q = populatedQueue(SIZE);
388          String s = q.toString();
389 <        for (int i = 0; i < N; ++i) {
389 >        for (int i = 0; i < SIZE; ++i) {
390              assertTrue(s.indexOf(String.valueOf(i)) >= 0);
391          }
392      }        
393  
394 <    public void testAddFirst(){
395 <        LinkedList q = fullQueue(3);
394 >    /**
395 >     *
396 >     */
397 >    public void testAddFirst() {
398 >        LinkedList q = populatedQueue(3);
399          q.addFirst(new Integer(4));
400          assertEquals(new Integer(4),q.get(0));
401      }  
402  
403 <    public void testAddLast(){
404 <        LinkedList q = fullQueue(3);
403 >    /**
404 >     *
405 >     */
406 >    public void testAddLast() {
407 >        LinkedList q = populatedQueue(3);
408          q.addLast(new Integer(3));
409          assertEquals(new Integer(3),q.get(3));
410      }
411      
412 +    /**
413 +     *
414 +     */
415      public void testGetFirst() {
416 <        LinkedList q = fullQueue(3);
416 >        LinkedList q = populatedQueue(3);
417          assertEquals(new Integer(0),q.getFirst());
418      }  
419      
420 +    /**
421 +     *
422 +     */
423      public void testGetLast() {
424 <        LinkedList q = fullQueue(3);
424 >        LinkedList q = populatedQueue(3);
425          assertEquals(new Integer(2),q.getLast());
426      }
427      
428 <    public void testIndexOf(){
429 <        LinkedList q = fullQueue(3);
428 >    /**
429 >     *
430 >     */
431 >    public void testIndexOf() {
432 >        LinkedList q = populatedQueue(3);
433          assertEquals(0,q.indexOf(new Integer(0)));
434          assertEquals(1,q.indexOf(new Integer(1)));
435          assertEquals(2,q.indexOf(new Integer(2)));
436          assertEquals(-1, q.indexOf("not there"));
437      }
438  
439 <    public void testLastIndexOf(){
440 <        LinkedList q = fullQueue(3);
439 >    /**
440 >     *
441 >     */
442 >    public void testLastIndexOf() {
443 >        LinkedList q = populatedQueue(3);
444          q.add(new Integer(2));
445          assertEquals(3,q.lastIndexOf(new Integer(2)));
446          assertEquals(-1, q.lastIndexOf("not there"));
447      }
448      
449 <    public void testSet(){
450 <        LinkedList q = fullQueue(3);
449 >    /**
450 >     *
451 >     */
452 >    public void testSet() {
453 >        LinkedList q = populatedQueue(3);
454          q.set(0,(new Integer(1)));
455          assertFalse(q.contains(new Integer(0)));
456          assertEquals(new Integer(1), q.get(0));
457      }
458      
459  
460 <    public void testGetFirst_NoSuchElementException(){
460 >    /**
461 >     *
462 >     */
463 >    public void testGetFirst_NoSuchElementException() {
464          try {
465              LinkedList l = new LinkedList();
466              l.getFirst();
467 <            fail("First Element");
467 >            shouldThrow();
468          }
469          catch(NoSuchElementException success) {}
470      }
471      
472 +    /**
473 +     *
474 +     */
475      public void testRemoveFirst() {
476          try {
477              LinkedList l = new LinkedList();
478              l.removeFirst();
479 <            fail("R: First Element");
479 >            shouldThrow();
480          }
481          catch(NoSuchElementException success) {}
482      }
483      
484 +    /**
485 +     *
486 +     */
487      public void testRemoveLast() {
488          try {
489              LinkedList l = new LinkedList();
490              l.removeLast();
491 <            fail("R: Last Element");  
491 >            shouldThrow();
492          }
493          catch(NoSuchElementException success) {}
494      }
495      
496 <    public void testGetLast_NoSuchElementException(){
496 >    /**
497 >     *
498 >     */
499 >    public void testGetLast_NoSuchElementException() {
500          try {
501              LinkedList l = new LinkedList();
502              l.getLast();
503 <            fail("Last Element");  
503 >            shouldThrow();
504          }
505          catch(NoSuchElementException success) {}
506      }
507  
508  
509 <    public void testAddAll_NullPointerException(){
509 >    /**
510 >     *
511 >     */
512 >    public void testAddAll_NullPointerException() {
513          try {
514              LinkedList l = new LinkedList();
515              l.addAll((Collection)null);
516 <            fail("Add All Failed");
516 >            shouldThrow();
517          }
518          catch(NullPointerException success){}
519      }
520      
521      
522 +    /**
523 +     *
524 +     */
525      public void testAddAll1_OutOfBounds() {
526          try {
527              LinkedList l = new LinkedList();
528              l.addAll(4,new LinkedList());
529 <            fail("boolean addAll(int, Collection) should throw IndexOutOfBoundsException");
529 >            shouldThrow();
530          }
531          catch(IndexOutOfBoundsException  success) {}
532      }
533      
534      
535 +    /**
536 +     *
537 +     */
538      public void testAddAll2_IndexOutOfBoundsException() {
539          try {
540              LinkedList l = new LinkedList();
# Line 428 | Line 542 | public class LinkedListTest extends Test
542              LinkedList m = new LinkedList();
543              m.add(new Object());
544              l.addAll(4,m);
545 <            fail("Add All Failed " + l.size());
546 <        }catch(IndexOutOfBoundsException  success) {}
545 >            shouldThrow();
546 >        } catch(IndexOutOfBoundsException  success) {}
547      }
548  
549 +    /**
550 +     *
551 +     */
552      public void testAddAll4_BadIndex() {
553          try {
554              LinkedList l = new LinkedList();
# Line 439 | Line 556 | public class LinkedListTest extends Test
556              LinkedList m = new LinkedList();
557              m.add(new Object());
558              l.addAll(-1,m);
559 <            fail("Add All Failed " + l.size());
560 <        }catch(IndexOutOfBoundsException  success){}
559 >            shouldThrow();
560 >        } catch(IndexOutOfBoundsException  success){}
561      }
562  
563 +    /**
564 +     *
565 +     */
566      public void testget1() {
567          try {
568              LinkedList l = new LinkedList();
569              l.add(new Object());
570              l.get(-1);
571 <            fail("get Failed - l.get(-1)");
572 <        }catch(IndexOutOfBoundsException  success) {}  
571 >            shouldThrow();
572 >        } catch(IndexOutOfBoundsException  success) {}  
573      }
574  
575 +    /**
576 +     *
577 +     */
578      public void testget2() {
579          try {
580              LinkedList l = new LinkedList();
581              l.add(new Object());
582              l.get(5);
583 <            fail("get Failed - l.get(5) l.size(): " + l.size());
584 <        }catch(IndexOutOfBoundsException  success){}    
583 >            shouldThrow();
584 >        } catch(IndexOutOfBoundsException  success){}  
585      }
586  
587 +    /**
588 +     *
589 +     */
590      public void testset1() {
591          try {
592              LinkedList l = new LinkedList();
593              l.add(new Object());
594              l.set(-1,new Object());
595 <            fail("set failed - l.set(-1,...)" + l.size());
596 <        }catch(IndexOutOfBoundsException  success){}    
595 >            shouldThrow();
596 >        } catch(IndexOutOfBoundsException  success){}  
597      }
598  
599 +    /**
600 +     *
601 +     */
602      public void testset2() {
603          try {
604              LinkedList l = new LinkedList();
605              l.add(new Object());
606              l.set(5,new Object());
607 <            fail("set failed = l.set(5,..) l.size():" + l.size());
608 <        }catch(IndexOutOfBoundsException  success){}    
607 >            shouldThrow();
608 >        } catch(IndexOutOfBoundsException  success){}  
609      }
610  
611 +    /**
612 +     *
613 +     */
614      public void testadd1() {
615          try {
616              LinkedList l = new LinkedList();
617              l.add(new Object());
618              l.add(-1,new Object());
619 <            fail("Add Failed - l.add(-1) l.size(): " + l.size());
620 <        }catch(IndexOutOfBoundsException  success){}    
619 >            shouldThrow();
620 >        } catch(IndexOutOfBoundsException  success){}  
621      }
622  
623 <    public void add2(){
623 >    public void add2() {
624          try {
625              LinkedList l = new LinkedList();
626              l.add(new Object());
627              l.add(5,new Object());
628 <            fail("Add Failed  l.add(f,...)");
629 <        }catch(IndexOutOfBoundsException  success) {}  
628 >            shouldThrow();
629 >        } catch(IndexOutOfBoundsException  success) {}  
630      }
631  
632 <    public void testremove(){
632 >    /**
633 >     *
634 >     */
635 >    public void testremove() {
636          try {
637              LinkedList l = new LinkedList();
638              l.add(new Object());
639              l.remove(-1);
640 <            fail("Remove Failed l.remove(-1); l.size():" + l.size());
641 <        }catch(IndexOutOfBoundsException  success){}
640 >            shouldThrow();
641 >        } catch(IndexOutOfBoundsException  success){}
642      }
643      
644 <    public void testremove1(){
644 >    /**
645 >     *
646 >     */
647 >    public void testremove1() {
648          try {
649              LinkedList l = new LinkedList();
650              l.add(new Object());
651              l.remove(5);
652 <            fail("Remove Failed l.remove(5); l.size():" + l.size());
653 <        }catch(IndexOutOfBoundsException  success){}
652 >            shouldThrow();
653 >        } catch(IndexOutOfBoundsException  success){}
654      }
655  
656      
657 <    public void testremove2(){
658 <        try{
657 >    /**
658 >     *
659 >     */
660 >    public void testremove2() {
661 >        try {
662              LinkedList l = new LinkedList();
663              l.remove();
664 <            fail("LinkedList - Object remove() should throw a NoSuchElementException");
665 <        }catch(NoSuchElementException e){}      
664 >            shouldThrow();
665 >        } catch(NoSuchElementException e){}    
666      }
667  
668 +    /**
669 +     *
670 +     */
671      public void testlistIt1() {
672          try {
673              LinkedList l = new LinkedList();
674              l.add(new Object());
675              l.listIterator(5);
676 <            fail("l.listIterator(5) l.size():" + l.size());
677 <        }catch(IndexOutOfBoundsException  success){}
676 >            shouldThrow();
677 >        } catch(IndexOutOfBoundsException  success){}
678      }
679      
680 +    /**
681 +     *
682 +     */
683      public void testlistIt2() {
684          try {
685              LinkedList l = new LinkedList();
686              l.add(new Object());
687              l.listIterator(-1);
688 <            fail("l.listIterator(-1) l.size():" + l.size());
689 <        }catch(IndexOutOfBoundsException  success){}
688 >            shouldThrow();
689 >        } catch(IndexOutOfBoundsException  success){}
690      }
691      
692 +    /**
693 +     *
694 +     */
695      public void testlistIt3() {
696          try {
697              LinkedList l = new LinkedList();
# Line 549 | Line 699 | public class LinkedListTest extends Test
699              ListIterator a = l.listIterator(0);
700              l.removeFirst();
701              a.next();
702 <            fail("l.listIterator(-1) l.size():" + l.size());
703 <        }catch(ConcurrentModificationException success){}
702 >            shouldThrow();
703 >        } catch(ConcurrentModificationException success){}
704      }
705  
706 +    /**
707 +     *
708 +     */
709      public void testToArray_BadArg() {
710          try {
711              LinkedList l = new LinkedList();
712              l.add(new Object());
713              Object o[] = l.toArray(null);
714 <            fail("l.toArray(null) did not throw an exception");
715 <        }catch(NullPointerException success){}
714 >            shouldThrow();
715 >        } catch(NullPointerException success){}
716      }
717  
718 +    /**
719 +     *
720 +     */
721      public void testToArray1_BadArg() {
722          try {
723              LinkedList l = new LinkedList();
724              l.add(new Integer(5));
725              Object o[] = l.toArray(new String[10] );
726 <            fail("l.toArray(String[] f) did not throw an exception, an Integer was added");
727 <        }catch(ArrayStoreException  success){}
726 >            shouldThrow();
727 >        } catch(ArrayStoreException  success){}
728      }
729  
730   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines