--- jsr166/src/test/tck/ConcurrentLinkedDequeTest.java 2015/04/25 04:55:30 1.19 +++ jsr166/src/test/tck/ConcurrentLinkedDequeTest.java 2015/05/23 00:53:08 1.21 @@ -65,8 +65,7 @@ public class ConcurrentLinkedDequeTest e */ public void testConstructor4() { try { - Integer[] ints = new Integer[SIZE]; - new ConcurrentLinkedDeque(Arrays.asList(ints)); + new ConcurrentLinkedDeque(Arrays.asList(new Integer[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -75,10 +74,10 @@ public class ConcurrentLinkedDequeTest e * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + ints[i] = new Integer(i); try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); new ConcurrentLinkedDeque(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} @@ -116,7 +115,7 @@ public class ConcurrentLinkedDequeTest e public void testSize() { ConcurrentLinkedDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.size()); + assertEquals(SIZE - i, q.size()); q.remove(); } for (int i = 0; i < SIZE; ++i) { @@ -129,8 +128,8 @@ public class ConcurrentLinkedDequeTest e * push(null) throws NPE */ public void testPushNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.push(null); shouldThrow(); } catch (NullPointerException success) {} @@ -164,8 +163,8 @@ public class ConcurrentLinkedDequeTest e * offer(null) throws NPE */ public void testOfferNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.offer(null); shouldThrow(); } catch (NullPointerException success) {} @@ -175,8 +174,8 @@ public class ConcurrentLinkedDequeTest e * offerFirst(null) throws NPE */ public void testOfferFirstNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.offerFirst(null); shouldThrow(); } catch (NullPointerException success) {} @@ -186,8 +185,8 @@ public class ConcurrentLinkedDequeTest e * offerLast(null) throws NPE */ public void testOfferLastNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.offerLast(null); shouldThrow(); } catch (NullPointerException success) {} @@ -230,8 +229,8 @@ public class ConcurrentLinkedDequeTest e * add(null) throws NPE */ public void testAddNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.add(null); shouldThrow(); } catch (NullPointerException success) {} @@ -241,8 +240,8 @@ public class ConcurrentLinkedDequeTest e * addFirst(null) throws NPE */ public void testAddFirstNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.addFirst(null); shouldThrow(); } catch (NullPointerException success) {} @@ -252,8 +251,8 @@ public class ConcurrentLinkedDequeTest e * addLast(null) throws NPE */ public void testAddLastNull() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.addLast(null); shouldThrow(); } catch (NullPointerException success) {} @@ -296,8 +295,8 @@ public class ConcurrentLinkedDequeTest e * addAll(null) throws NPE */ public void testAddAll1() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); q.addAll(null); shouldThrow(); } catch (NullPointerException success) {} @@ -307,8 +306,8 @@ public class ConcurrentLinkedDequeTest e * addAll(this) throws IAE */ public void testAddAllSelf() { + ConcurrentLinkedDeque q = populatedDeque(SIZE); try { - ConcurrentLinkedDeque q = populatedDeque(SIZE); q.addAll(q); shouldThrow(); } catch (IllegalArgumentException success) {} @@ -318,10 +317,9 @@ public class ConcurrentLinkedDequeTest e * addAll of a collection with null elements throws NPE */ public void testAddAll2() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(new Integer[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -331,11 +329,11 @@ public class ConcurrentLinkedDequeTest e * possibly adding some elements */ public void testAddAll3() { + ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + ints[i] = new Integer(i); try { - ConcurrentLinkedDeque q = new ConcurrentLinkedDeque(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} @@ -372,7 +370,7 @@ public class ConcurrentLinkedDequeTest e */ public void testPollLast() { ConcurrentLinkedDeque q = populatedDeque(SIZE); - for (int i = SIZE-1; i >= 0; --i) { + for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.pollLast()); } assertNull(q.pollLast()); @@ -472,7 +470,7 @@ public class ConcurrentLinkedDequeTest e */ public void testPeekLast() { ConcurrentLinkedDeque q = populatedDeque(SIZE); - for (int i = SIZE-1; i >= 0; --i) { + for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.peekLast()); assertEquals(i, q.pollLast()); assertTrue(q.peekLast() == null || @@ -501,7 +499,7 @@ public class ConcurrentLinkedDequeTest e */ public void testLastElement() { ConcurrentLinkedDeque q = populatedDeque(SIZE); - for (int i = SIZE-1; i >= 0; --i) { + for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.getLast()); assertEquals(i, q.pollLast()); } @@ -626,7 +624,7 @@ public class ConcurrentLinkedDequeTest e assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); + assertEquals(SIZE - i, q.size()); p.remove(); } } @@ -639,7 +637,7 @@ public class ConcurrentLinkedDequeTest e ConcurrentLinkedDeque q = populatedDeque(SIZE); ConcurrentLinkedDeque p = populatedDeque(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); + assertEquals(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { Integer x = (Integer)(p.remove()); assertFalse(q.contains(x));