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

Comparing jsr166/src/test/tck/PriorityQueueTest.java (file contents):
Revision 1.11 by jsr166, Mon Nov 16 05:30:08 2009 UTC vs.
Revision 1.12 by jsr166, Sat Nov 21 02:07:27 2009 UTC

# Line 13 | Line 13 | import java.io.*;
13  
14   public class PriorityQueueTest extends JSR166TestCase {
15      public static void main(String[] args) {
16 <        junit.textui.TestRunner.run (suite());
16 >        junit.textui.TestRunner.run (suite());
17      }
18      public static Test suite() {
19 <        return new TestSuite(PriorityQueueTest.class);
19 >        return new TestSuite(PriorityQueueTest.class);
20      }
21  
22      static class MyReverseComparator implements Comparator {
# Line 36 | Line 36 | public class PriorityQueueTest extends J
36      private PriorityQueue populatedQueue(int n) {
37          PriorityQueue q = new PriorityQueue(n);
38          assertTrue(q.isEmpty());
39 <        for (int i = n-1; i >= 0; i-=2)
40 <            assertTrue(q.offer(new Integer(i)));
41 <        for (int i = (n & 1); i < n; i+=2)
42 <            assertTrue(q.offer(new Integer(i)));
39 >        for (int i = n-1; i >= 0; i-=2)
40 >            assertTrue(q.offer(new Integer(i)));
41 >        for (int i = (n & 1); i < n; i+=2)
42 >            assertTrue(q.offer(new Integer(i)));
43          assertFalse(q.isEmpty());
44 <        assertEquals(n, q.size());
44 >        assertEquals(n, q.size());
45          return q;
46      }
47  
# Line 166 | Line 166 | public class PriorityQueueTest extends J
166       * offer(null) throws NPE
167       */
168      public void testOfferNull() {
169 <        try {
169 >        try {
170              PriorityQueue q = new PriorityQueue(1);
171              q.offer(null);
172              shouldThrow();
# Line 177 | Line 177 | public class PriorityQueueTest extends J
177       * add(null) throws NPE
178       */
179      public void testAddNull() {
180 <        try {
180 >        try {
181              PriorityQueue q = new PriorityQueue(1);
182              q.add(null);
183              shouldThrow();
# Line 283 | Line 283 | public class PriorityQueueTest extends J
283          for (int i = 0; i < SIZE; ++i) {
284              assertEquals(i, ((Integer)q.poll()).intValue());
285          }
286 <        assertNull(q.poll());
286 >        assertNull(q.poll());
287      }
288  
289      /**
# Line 297 | Line 297 | public class PriorityQueueTest extends J
297              assertTrue(q.peek() == null ||
298                         i != ((Integer)q.peek()).intValue());
299          }
300 <        assertNull(q.peek());
300 >        assertNull(q.peek());
301      }
302  
303      /**
# Line 328 | Line 328 | public class PriorityQueueTest extends J
328              q.remove();
329              shouldThrow();
330          } catch (NoSuchElementException success) {
331 <        }
331 >        }
332      }
333  
334      /**
# Line 426 | Line 426 | public class PriorityQueueTest extends J
426       */
427      public void testToArray() {
428          PriorityQueue q = populatedQueue(SIZE);
429 <        Object[] o = q.toArray();
429 >        Object[] o = q.toArray();
430          Arrays.sort(o);
431 <        for (int i = 0; i < o.length; i++)
432 <            assertEquals(o[i], q.poll());
431 >        for (int i = 0; i < o.length; i++)
432 >            assertEquals(o[i], q.poll());
433      }
434  
435      /**
# Line 437 | Line 437 | public class PriorityQueueTest extends J
437       */
438      public void testToArray2() {
439          PriorityQueue q = populatedQueue(SIZE);
440 <        Integer[] ints = new Integer[SIZE];
441 <        ints = (Integer[])q.toArray(ints);
440 >        Integer[] ints = new Integer[SIZE];
441 >        ints = (Integer[])q.toArray(ints);
442          Arrays.sort(ints);
443          for (int i = 0; i < ints.length; i++)
444              assertEquals(ints[i], q.poll());
# Line 450 | Line 450 | public class PriorityQueueTest extends J
450      public void testIterator() {
451          PriorityQueue q = populatedQueue(SIZE);
452          int i = 0;
453 <        Iterator it = q.iterator();
453 >        Iterator it = q.iterator();
454          while (it.hasNext()) {
455              assertTrue(q.contains(it.next()));
456              ++i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines