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

Comparing jsr166/src/test/tck/ConcurrentLinkedDequeTest.java (file contents):
Revision 1.14 by jsr166, Wed Dec 31 19:05:42 2014 UTC vs.
Revision 1.18 by jsr166, Sun Feb 22 04:34:44 2015 UTC

# Line 55 | Line 55 | public class ConcurrentLinkedDequeTest e
55       */
56      public void testConstructor3() {
57          try {
58 <            ConcurrentLinkedDeque q = new ConcurrentLinkedDeque((Collection)null);
58 >            new ConcurrentLinkedDeque((Collection)null);
59              shouldThrow();
60          } catch (NullPointerException success) {}
61      }
# Line 66 | Line 66 | public class ConcurrentLinkedDequeTest e
66      public void testConstructor4() {
67          try {
68              Integer[] ints = new Integer[SIZE];
69 <            ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(Arrays.asList(ints));
69 >            new ConcurrentLinkedDeque(Arrays.asList(ints));
70              shouldThrow();
71          } catch (NullPointerException success) {}
72      }
# Line 79 | Line 79 | public class ConcurrentLinkedDequeTest e
79              Integer[] ints = new Integer[SIZE];
80              for (int i = 0; i < SIZE-1; ++i)
81                  ints[i] = new Integer(i);
82 <            ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(Arrays.asList(ints));
82 >            new ConcurrentLinkedDeque(Arrays.asList(ints));
83              shouldThrow();
84          } catch (NullPointerException success) {}
85      }
# Line 437 | Line 437 | public class ConcurrentLinkedDequeTest e
437       */
438      public void testRemoveElement() {
439          ConcurrentLinkedDeque q = populatedDeque(SIZE);
440 <        for (int i = 1; i < SIZE; i+=2) {
440 >        for (int i = 1; i < SIZE; i += 2) {
441              assertTrue(q.contains(i));
442              assertTrue(q.remove(i));
443              assertFalse(q.contains(i));
444              assertTrue(q.contains(i-1));
445          }
446 <        for (int i = 0; i < SIZE; i+=2) {
446 >        for (int i = 0; i < SIZE; i += 2) {
447              assertTrue(q.contains(i));
448              assertTrue(q.remove(i));
449              assertFalse(q.contains(i));
# Line 547 | Line 547 | public class ConcurrentLinkedDequeTest e
547       */
548      public void testRemoveFirstOccurrence() {
549          ConcurrentLinkedDeque q = populatedDeque(SIZE);
550 <        for (int i = 1; i < SIZE; i+=2) {
550 >        for (int i = 1; i < SIZE; i += 2) {
551              assertTrue(q.removeFirstOccurrence(new Integer(i)));
552          }
553 <        for (int i = 0; i < SIZE; i+=2) {
553 >        for (int i = 0; i < SIZE; i += 2) {
554              assertTrue(q.removeFirstOccurrence(new Integer(i)));
555              assertFalse(q.removeFirstOccurrence(new Integer(i+1)));
556          }
# Line 562 | Line 562 | public class ConcurrentLinkedDequeTest e
562       */
563      public void testRemoveLastOccurrence() {
564          ConcurrentLinkedDeque q = populatedDeque(SIZE);
565 <        for (int i = 1; i < SIZE; i+=2) {
565 >        for (int i = 1; i < SIZE; i += 2) {
566              assertTrue(q.removeLastOccurrence(new Integer(i)));
567          }
568 <        for (int i = 0; i < SIZE; i+=2) {
568 >        for (int i = 0; i < SIZE; i += 2) {
569              assertTrue(q.removeLastOccurrence(new Integer(i)));
570              assertFalse(q.removeLastOccurrence(new Integer(i+1)));
571          }
# Line 641 | Line 641 | public class ConcurrentLinkedDequeTest e
641              assertTrue(q.removeAll(p));
642              assertEquals(SIZE-i, q.size());
643              for (int j = 0; j < i; ++j) {
644 <                Integer I = (Integer)(p.remove());
645 <                assertFalse(q.contains(I));
644 >                Integer x = (Integer)(p.remove());
645 >                assertFalse(q.contains(x));
646              }
647          }
648      }
# Line 696 | Line 696 | public class ConcurrentLinkedDequeTest e
696       */
697      public void testIterator() {
698          ConcurrentLinkedDeque q = populatedDeque(SIZE);
699        int i = 0;
699          Iterator it = q.iterator();
700 <        while (it.hasNext()) {
700 >        int i;
701 >        for (i = 0; it.hasNext(); i++)
702              assertTrue(q.contains(it.next()));
703            ++i;
704        }
703          assertEquals(i, SIZE);
704 +        assertIteratorExhausted(it);
705 +    }
706 +
707 +    /**
708 +     * iterator of empty collection has no elements
709 +     */
710 +    public void testEmptyIterator() {
711 +        Deque c = new ConcurrentLinkedDeque();
712 +        assertIteratorExhausted(c.iterator());
713 +        assertIteratorExhausted(c.descendingIterator());
714      }
715  
716      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines