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

Comparing jsr166/src/test/tck/ConcurrentLinkedQueueTest.java (file contents):
Revision 1.22 by jsr166, Thu Nov 4 01:04:54 2010 UTC vs.
Revision 1.26 by jsr166, Fri May 27 19:49:56 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
# Line 25 | Line 25 | public class ConcurrentLinkedQueueTest e
25       * Create a queue of given size containing consecutive
26       * Integers 0 ... n.
27       */
28 <    private ConcurrentLinkedQueue populatedQueue(int n) {
29 <        ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
28 >    private ConcurrentLinkedQueue<Integer> populatedQueue(int n) {
29 >        ConcurrentLinkedQueue<Integer> q = new ConcurrentLinkedQueue<Integer>();
30          assertTrue(q.isEmpty());
31          for (int i = 0; i < n; ++i)
32              assertTrue(q.offer(new Integer(i)));
# Line 139 | Line 139 | public class ConcurrentLinkedQueueTest e
139          } catch (NullPointerException success) {}
140      }
141  
142
142      /**
143       * Offer returns true
144       */
# Line 284 | Line 283 | public class ConcurrentLinkedQueueTest e
283      public void testRemoveElement() {
284          ConcurrentLinkedQueue q = populatedQueue(SIZE);
285          for (int i = 1; i < SIZE; i+=2) {
286 <            assertTrue(q.remove(new Integer(i)));
286 >            assertTrue(q.contains(i));
287 >            assertTrue(q.remove(i));
288 >            assertFalse(q.contains(i));
289 >            assertTrue(q.contains(i-1));
290          }
291          for (int i = 0; i < SIZE; i+=2) {
292 <            assertTrue(q.remove(new Integer(i)));
293 <            assertFalse(q.remove(new Integer(i+1)));
292 >            assertTrue(q.contains(i));
293 >            assertTrue(q.remove(i));
294 >            assertFalse(q.contains(i));
295 >            assertFalse(q.remove(i+1));
296 >            assertFalse(q.contains(i+1));
297          }
298          assertTrue(q.isEmpty());
299      }
# Line 382 | Line 387 | public class ConcurrentLinkedQueueTest e
387       * toArray(a) contains all elements in FIFO order
388       */
389      public void testToArray2() {
390 <        ConcurrentLinkedQueue q = populatedQueue(SIZE);
390 >        ConcurrentLinkedQueue<Integer> q = populatedQueue(SIZE);
391          Integer[] ints = new Integer[SIZE];
392 <        assertSame(ints, q.toArray(ints));
392 >        Integer[] array = q.toArray(ints);
393 >        assertSame(ints, array);
394          for (int i = 0; i < ints.length; i++)
395              assertSame(ints[i], q.poll());
396      }
# Line 476 | Line 482 | public class ConcurrentLinkedQueueTest e
482          assertFalse(it.hasNext());
483      }
484  
479
485      /**
486       * toString contains toStrings of elements
487       */
# Line 484 | Line 489 | public class ConcurrentLinkedQueueTest e
489          ConcurrentLinkedQueue q = populatedQueue(SIZE);
490          String s = q.toString();
491          for (int i = 0; i < SIZE; ++i) {
492 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
492 >            assertTrue(s.contains(String.valueOf(i)));
493          }
494      }
495  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines