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.5 by dl, Sat Sep 20 18:20:08 2003 UTC vs.
Revision 1.6 by dl, Thu Sep 25 11:02:41 2003 UTC

# Line 11 | Line 11 | import java.util.concurrent.*;
11   import java.io.*;
12  
13   public class PriorityQueueTest extends JSR166TestCase {
14
14      public static void main(String[] args) {
15          junit.textui.TestRunner.run (suite());  
16      }
18
17      public static Test suite() {
18          return new TestSuite(PriorityQueueTest.class);
19      }
# Line 30 | Line 28 | public class PriorityQueueTest extends J
28          }
29      }
30  
33
31      /**
32       * Create a queue of given size containing consecutive
33       * Integers 0 ... n.
# Line 48 | Line 45 | public class PriorityQueueTest extends J
45      }
46  
47      /**
48 <     *
48 >     * A new queue has unbounded capacity
49       */
50      public void testConstructor1() {
51          assertEquals(0, new PriorityQueue(SIZE).size());
52      }
53  
54      /**
55 <     *
55 >     * Constructor throws IAE if  capacity argument nonpositive
56       */
57      public void testConstructor2() {
58          try {
# Line 66 | Line 63 | public class PriorityQueueTest extends J
63      }
64  
65      /**
66 <     *
66 >     * Initializing from null Collection throws NPE
67       */
68      public void testConstructor3() {
72
69          try {
70              PriorityQueue q = new PriorityQueue((Collection)null);
71              shouldThrow();
# Line 78 | Line 74 | public class PriorityQueueTest extends J
74      }
75  
76      /**
77 <     *
77 >     * Initializing from Collection of null elements throws NPE
78       */
79      public void testConstructor4() {
80          try {
# Line 90 | Line 86 | public class PriorityQueueTest extends J
86      }
87  
88      /**
89 <     *
89 >     * Initializing from Collection with some null elements throws NPE
90       */
91      public void testConstructor5() {
92          try {
# Line 104 | Line 100 | public class PriorityQueueTest extends J
100      }
101  
102      /**
103 <     *
103 >     * Queue contains all elements of collection used to initialize
104       */
105      public void testConstructor6() {
106          try {
# Line 119 | Line 115 | public class PriorityQueueTest extends J
115      }
116  
117      /**
118 <     *
118 >     * The comparator used in constructor is used
119       */
120      public void testConstructor7() {
121          try {
# Line 137 | Line 133 | public class PriorityQueueTest extends J
133      }
134  
135      /**
136 <     *
136 >     * isEmpty is true before add, false after
137       */
138      public void testEmpty() {
139          PriorityQueue q = new PriorityQueue(2);
# Line 151 | Line 147 | public class PriorityQueueTest extends J
147      }
148  
149      /**
150 <     *
150 >     * size changes when elements added and removed
151       */
152      public void testSize() {
153          PriorityQueue q = populatedQueue(SIZE);
# Line 166 | Line 162 | public class PriorityQueueTest extends J
162      }
163  
164      /**
165 <     *
165 >     * offer(null) throws NPE
166       */
167      public void testOfferNull() {
168          try {
# Line 177 | Line 173 | public class PriorityQueueTest extends J
173      }
174  
175      /**
176 <     *
176 >     * Offer of comparable element succeeds
177       */
178      public void testOffer() {
179          PriorityQueue q = new PriorityQueue(1);
180 <        assertTrue(q.offer(new Integer(0)));
181 <        assertTrue(q.offer(new Integer(1)));
180 >        assertTrue(q.offer(zero));
181 >        assertTrue(q.offer(one));
182      }
183  
184      /**
185 <     *
185 >     * Offer of non-Comparable throws CCE
186       */
187      public void testOfferNonComparable() {
188          try {
# Line 200 | Line 196 | public class PriorityQueueTest extends J
196      }
197  
198      /**
199 <     *
199 >     * add of comparable succeeds
200       */
201      public void testAdd() {
202          PriorityQueue q = new PriorityQueue(SIZE);
# Line 211 | Line 207 | public class PriorityQueueTest extends J
207      }
208  
209      /**
210 <     *
210 >     * addAll(null) throws NPE
211       */
212      public void testAddAll1() {
213          try {
# Line 222 | Line 218 | public class PriorityQueueTest extends J
218          catch (NullPointerException success) {}
219      }
220      /**
221 <     *
221 >     * addAll of a collection with null elements throws NPE
222       */
223      public void testAddAll2() {
224          try {
# Line 234 | Line 230 | public class PriorityQueueTest extends J
230          catch (NullPointerException success) {}
231      }
232      /**
233 <     *
233 >     * addAll of a collection with any null elements throws NPE after
234 >     * possibly adding some elements
235       */
236      public void testAddAll3() {
237          try {
# Line 249 | Line 246 | public class PriorityQueueTest extends J
246      }
247  
248      /**
249 <     *
249 >     * Queue contains all elements of successful addAll
250       */
251      public void testAddAll5() {
252          try {
# Line 267 | Line 264 | public class PriorityQueueTest extends J
264      }
265  
266      /**
267 <     *
267 >     * poll succeeds unless empty
268       */
269      public void testPoll() {
270          PriorityQueue q = populatedQueue(SIZE);
# Line 278 | Line 275 | public class PriorityQueueTest extends J
275      }
276  
277      /**
278 <     *
278 >     * peek returns next element, or null if empty
279       */
280      public void testPeek() {
281          PriorityQueue q = populatedQueue(SIZE);
# Line 292 | Line 289 | public class PriorityQueueTest extends J
289      }
290  
291      /**
292 <     *
292 >     * element returns next element, or throws NSEE if empty
293       */
294      public void testElement() {
295          PriorityQueue q = populatedQueue(SIZE);
# Line 308 | Line 305 | public class PriorityQueueTest extends J
305      }
306  
307      /**
308 <     *
308 >     * remove removes next element, or throws NSEE if empty
309       */
310      public void testRemove() {
311          PriorityQueue q = populatedQueue(SIZE);
# Line 323 | Line 320 | public class PriorityQueueTest extends J
320      }
321  
322      /**
323 <     *
323 >     * remove(x) removes x and returns true if present
324       */
325      public void testRemoveElement() {
326          PriorityQueue q = populatedQueue(SIZE);
# Line 338 | Line 335 | public class PriorityQueueTest extends J
335      }
336          
337      /**
338 <     *
338 >     * contains(x) reports true when elements added but not yet removed
339       */
340      public void testContains() {
341          PriorityQueue q = populatedQueue(SIZE);
# Line 350 | Line 347 | public class PriorityQueueTest extends J
347      }
348  
349      /**
350 <     *
350 >     * clear removes all elements
351       */
352      public void testClear() {
353          PriorityQueue q = populatedQueue(SIZE);
# Line 364 | Line 361 | public class PriorityQueueTest extends J
361      }
362  
363      /**
364 <     *
364 >     * containsAll(c) is true when c contains a subset of elements
365       */
366      public void testContainsAll() {
367          PriorityQueue q = populatedQueue(SIZE);
# Line 378 | Line 375 | public class PriorityQueueTest extends J
375      }
376  
377      /**
378 <     *
378 >     * retainAll(c) retains only those elements of c and reports true if changed
379       */
380      public void testRetainAll() {
381          PriorityQueue q = populatedQueue(SIZE);
# Line 397 | Line 394 | public class PriorityQueueTest extends J
394      }
395  
396      /**
397 <     *
397 >     * removeAll(c) removes only those elements of c and reports true if changed
398       */
399      public void testRemoveAll() {
400          for (int i = 1; i < SIZE; ++i) {
# Line 413 | Line 410 | public class PriorityQueueTest extends J
410      }
411  
412      /**
413 <     *
413 >     * toArray contains all elements
414       */
415      public void testToArray() {
416          PriorityQueue q = populatedQueue(SIZE);
# Line 424 | Line 421 | public class PriorityQueueTest extends J
421      }
422  
423      /**
424 <     *
424 >     * toArray(a) contains all elements
425       */
426      public void testToArray2() {
427          PriorityQueue q = populatedQueue(SIZE);
# Line 436 | Line 433 | public class PriorityQueueTest extends J
433      }
434      
435      /**
436 <     *
436 >     * iterator iterates through all elements
437       */
438      public void testIterator() {
439          PriorityQueue q = populatedQueue(SIZE);
# Line 450 | Line 447 | public class PriorityQueueTest extends J
447      }
448  
449      /**
450 <     *
450 >     * iterator.remove removes current element
451       */
452      public void testIteratorRemove () {
453          final PriorityQueue q = new PriorityQueue(3);
# Line 470 | Line 467 | public class PriorityQueueTest extends J
467  
468  
469      /**
470 <     *
470 >     * toString contains toStrings of elements
471       */
472      public void testToString() {
473          PriorityQueue q = populatedQueue(SIZE);
# Line 481 | Line 478 | public class PriorityQueueTest extends J
478      }        
479  
480      /**
481 <     *
481 >     * A deserialized serialized queue has same elements
482       */
483      public void testSerialization() {
484          PriorityQueue q = populatedQueue(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines