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.13 by jsr166, Sat Nov 21 02:07:27 2009 UTC vs.
Revision 1.14 by jsr166, Sat Nov 21 02:39:41 2009 UTC

# Line 47 | Line 47 | public class LinkedListTest extends JSR1
47          try {
48              LinkedList q = new LinkedList((Collection)null);
49              shouldThrow();
50 <        }
51 <        catch (NullPointerException success) {}
50 >        } catch (NullPointerException success) {}
51      }
52  
53      /**
54       * Queue contains all elements of collection used to initialize
56
55       */
56      public void testConstructor6() {
57 <        try {
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 < SIZE; ++i)
65 <                assertEquals(ints[i], q.poll());
66 <        }
67 <        finally {}
57 >        Integer[] ints = new Integer[SIZE];
58 >        for (int i = 0; i < SIZE; ++i)
59 >            ints[i] = new Integer(i);
60 >        LinkedList q = new LinkedList(Arrays.asList(ints));
61 >        for (int i = 0; i < SIZE; ++i)
62 >            assertEquals(ints[i], q.poll());
63      }
64  
65      /**
# Line 100 | Line 95 | public class LinkedListTest extends JSR1
95       * offer(null) succeeds
96       */
97      public void testOfferNull() {
98 <        try {
99 <            LinkedList q = new LinkedList();
105 <            q.offer(null);
106 <        } catch (NullPointerException ie) {
107 <            unexpectedException();
108 <        }
98 >        LinkedList q = new LinkedList();
99 >        q.offer(null);
100      }
101  
102      /**
# Line 136 | Line 127 | public class LinkedListTest extends JSR1
127              LinkedList q = new LinkedList();
128              q.addAll(null);
129              shouldThrow();
130 <        }
140 <        catch (NullPointerException success) {}
130 >        } catch (NullPointerException success) {}
131      }
132  
133      /**
134       * Queue contains all elements, in traversal order, of successful addAll
135       */
136      public void testAddAll5() {
137 <        try {
138 <            Integer[] empty = new Integer[0];
139 <            Integer[] ints = new Integer[SIZE];
140 <            for (int i = 0; i < SIZE; ++i)
141 <                ints[i] = new Integer(i);
142 <            LinkedList q = new LinkedList();
143 <            assertFalse(q.addAll(Arrays.asList(empty)));
144 <            assertTrue(q.addAll(Arrays.asList(ints)));
145 <            for (int i = 0; i < SIZE; ++i)
156 <                assertEquals(ints[i], q.poll());
157 <        }
158 <        finally {}
137 >        Integer[] empty = new Integer[0];
138 >        Integer[] ints = new Integer[SIZE];
139 >        for (int i = 0; i < SIZE; ++i)
140 >            ints[i] = new Integer(i);
141 >        LinkedList q = new LinkedList();
142 >        assertFalse(q.addAll(Arrays.asList(empty)));
143 >        assertTrue(q.addAll(Arrays.asList(ints)));
144 >        for (int i = 0; i < SIZE; ++i)
145 >            assertEquals(ints[i], q.poll());
146      }
147  
148      /**
149       * addAll with too large an index throws IOOBE
150       */
151      public void testAddAll2_IndexOutOfBoundsException() {
152 +        LinkedList l = new LinkedList();
153 +        l.add(new Object());
154 +        LinkedList m = new LinkedList();
155 +        m.add(new Object());
156          try {
166            LinkedList l = new LinkedList();
167            l.add(new Object());
168            LinkedList m = new LinkedList();
169            m.add(new Object());
157              l.addAll(4,m);
158              shouldThrow();
159          } catch (IndexOutOfBoundsException  success) {}
# Line 176 | Line 163 | public class LinkedListTest extends JSR1
163       * addAll with negative index throws IOOBE
164       */
165      public void testAddAll4_BadIndex() {
166 +        LinkedList l = new LinkedList();
167 +        l.add(new Object());
168 +        LinkedList m = new LinkedList();
169 +        m.add(new Object());
170          try {
180            LinkedList l = new LinkedList();
181            l.add(new Object());
182            LinkedList m = new LinkedList();
183            m.add(new Object());
171              l.addAll(-1,m);
172              shouldThrow();
173          } catch (IndexOutOfBoundsException  success) {}
# Line 223 | Line 210 | public class LinkedListTest extends JSR1
210          try {
211              q.element();
212              shouldThrow();
213 <        }
227 <        catch (NoSuchElementException success) {}
213 >        } catch (NoSuchElementException success) {}
214      }
215  
216      /**
# Line 238 | Line 224 | public class LinkedListTest extends JSR1
224          try {
225              q.remove();
226              shouldThrow();
227 <        } catch (NoSuchElementException success) {
242 <        }
227 >        } catch (NoSuchElementException success) {}
228      }
229  
230      /**
# Line 376 | Line 361 | public class LinkedListTest extends JSR1
361              l.add(new Integer(5));
362              Object o[] = l.toArray(new String[10] );
363              shouldThrow();
364 <        } catch (ArrayStoreException  success) {}
364 >        } catch (ArrayStoreException success) {}
365      }
366  
367      /**
# Line 442 | Line 427 | public class LinkedListTest extends JSR1
427          assertFalse(it.hasNext());
428          try {
429              it.next();
430 <        } catch (NoSuchElementException success) {
431 <        }
430 >            shouldThrow();
431 >        } catch (NoSuchElementException success) {}
432      }
433  
434      /**
# Line 522 | Line 507 | public class LinkedListTest extends JSR1
507          try {
508              q.pop();
509              shouldThrow();
510 <        } catch (NoSuchElementException success) {
526 <        }
510 >        } catch (NoSuchElementException success) {}
511      }
512  
513      /**
# Line 593 | Line 577 | public class LinkedListTest extends JSR1
577          try {
578              q.getFirst();
579              shouldThrow();
580 <        }
597 <        catch (NoSuchElementException success) {}
580 >        } catch (NoSuchElementException success) {}
581      }
582  
583      /**
# Line 609 | Line 592 | public class LinkedListTest extends JSR1
592          try {
593              q.getLast();
594              shouldThrow();
595 <        }
613 <        catch (NoSuchElementException success) {}
595 >        } catch (NoSuchElementException success) {}
596          assertNull(q.peekLast());
597      }
598  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines