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

Comparing jsr166/src/test/tck/LinkedTransferQueueTest.java (file contents):
Revision 1.41 by jsr166, Thu Nov 18 18:49:44 2010 UTC vs.
Revision 1.44 by jsr166, Tue Mar 15 19:47:06 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 John Vint
6   */
7  
# Line 40 | Line 40 | public class LinkedTransferQueueTest ext
40                              new Generic().testSuite());
41      }
42  
43    void checkEmpty(BlockingQueue q) {
44        try {
45            assertTrue(q.isEmpty());
46            assertEquals(0, q.size());
47            assertNull(q.peek());
48            assertNull(q.poll());
49            assertNull(q.poll(0, MILLISECONDS));
50            assertEquals(q.toString(), "[]");
51            assertTrue(Arrays.equals(q.toArray(), new Object[0]));
52            assertFalse(q.iterator().hasNext());
53            try {
54                q.element();
55                shouldThrow();
56            } catch (NoSuchElementException success) {}
57            try {
58                q.iterator().next();
59                shouldThrow();
60            } catch (NoSuchElementException success) {}
61            try {
62                q.remove();
63                shouldThrow();
64            } catch (NoSuchElementException success) {}
65        } catch (InterruptedException ie) {
66            threadUnexpectedException(ie);
67        }
68    }
69
43      /**
44       * Constructor builds new queue with size being zero and empty
45       * being true
# Line 448 | Line 421 | public class LinkedTransferQueueTest ext
421       */
422      public void testRemoveElement() throws InterruptedException {
423          LinkedTransferQueue q = populatedQueue(SIZE);
424 <        for (int i = 1; i < SIZE; i += 2) {
424 >        for (int i = 1; i < SIZE; i+=2) {
425 >            assertTrue(q.contains(i));
426              assertTrue(q.remove(i));
427 +            assertFalse(q.contains(i));
428 +            assertTrue(q.contains(i-1));
429          }
430 <        for (int i = 0; i < SIZE; i += 2) {
430 >        for (int i = 0; i < SIZE; i+=2) {
431 >            assertTrue(q.contains(i));
432              assertTrue(q.remove(i));
433 <            assertFalse(q.remove(i + 1));
433 >            assertFalse(q.contains(i));
434 >            assertFalse(q.remove(i+1));
435 >            assertFalse(q.contains(i+1));
436          }
437          checkEmpty(q);
438      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines