--- jsr166/src/test/tck/ArrayDequeTest.java 2014/12/31 19:05:42 1.30 +++ jsr166/src/test/tck/ArrayDequeTest.java 2015/04/25 04:55:30 1.34 @@ -18,7 +18,7 @@ import junit.framework.TestSuite; public class ArrayDequeTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { @@ -51,7 +51,7 @@ public class ArrayDequeTest extends JSR1 */ public void testConstructor3() { try { - ArrayDeque q = new ArrayDeque((Collection)null); + new ArrayDeque((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -62,7 +62,7 @@ public class ArrayDequeTest extends JSR1 public void testConstructor4() { try { Integer[] ints = new Integer[SIZE]; - ArrayDeque q = new ArrayDeque(Arrays.asList(ints)); + new ArrayDeque(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} } @@ -75,7 +75,7 @@ public class ArrayDequeTest extends JSR1 Integer[] ints = new Integer[SIZE]; for (int i = 0; i < SIZE-1; ++i) ints[i] = new Integer(i); - ArrayDeque q = new ArrayDeque(Arrays.asList(ints)); + new ArrayDeque(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} } @@ -393,13 +393,13 @@ public class ArrayDequeTest extends JSR1 */ public void testRemoveElement() { ArrayDeque q = populatedDeque(SIZE); - for (int i = 1; i < SIZE; i+=2) { + for (int i = 1; i < SIZE; i += 2) { assertTrue(q.contains(i)); assertTrue(q.remove(i)); assertFalse(q.contains(i)); assertTrue(q.contains(i-1)); } - for (int i = 0; i < SIZE; i+=2) { + for (int i = 0; i < SIZE; i += 2) { assertTrue(q.contains(i)); assertTrue(q.remove(i)); assertFalse(q.contains(i)); @@ -532,10 +532,10 @@ public class ArrayDequeTest extends JSR1 */ public void testRemoveFirstOccurrence() { ArrayDeque q = populatedDeque(SIZE); - for (int i = 1; i < SIZE; i+=2) { + for (int i = 1; i < SIZE; i += 2) { assertTrue(q.removeFirstOccurrence(new Integer(i))); } - for (int i = 0; i < SIZE; i+=2) { + for (int i = 0; i < SIZE; i += 2) { assertTrue(q.removeFirstOccurrence(new Integer(i))); assertFalse(q.removeFirstOccurrence(new Integer(i+1))); } @@ -547,10 +547,10 @@ public class ArrayDequeTest extends JSR1 */ public void testRemoveLastOccurrence() { ArrayDeque q = populatedDeque(SIZE); - for (int i = 1; i < SIZE; i+=2) { + for (int i = 1; i < SIZE; i += 2) { assertTrue(q.removeLastOccurrence(new Integer(i))); } - for (int i = 0; i < SIZE; i+=2) { + for (int i = 0; i < SIZE; i += 2) { assertTrue(q.removeLastOccurrence(new Integer(i))); assertFalse(q.removeLastOccurrence(new Integer(i+1))); } @@ -742,13 +742,21 @@ public class ArrayDequeTest extends JSR1 */ public void testIterator() { ArrayDeque q = populatedDeque(SIZE); - int i = 0; Iterator it = q.iterator(); - while (it.hasNext()) { + int i; + for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next())); - ++i; - } assertEquals(i, SIZE); + assertIteratorExhausted(it); + } + + /** + * iterator of empty collection has no elements + */ + public void testEmptyIterator() { + Deque c = new ArrayDeque(); + assertIteratorExhausted(c.iterator()); + assertIteratorExhausted(c.descendingIterator()); } /**