--- jsr166/src/test/tck/ArrayDequeTest.java 2016/10/17 00:59:53 1.43 +++ jsr166/src/test/tck/ArrayDequeTest.java 2016/10/17 15:27:57 1.46 @@ -1,6 +1,7 @@ /* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at + * Written by Doug Lea and Martin Buchholz with assistance from + * members of JCP JSR-166 Expert Group and released to the public + * domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ */ @@ -13,6 +14,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Queue; import java.util.Random; +import java.util.Spliterator; import java.util.concurrent.ThreadLocalRandom; import junit.framework.Test; @@ -26,7 +28,7 @@ public class ArrayDequeTest extends JSR1 public static Test suite() { class Implementation implements CollectionImplementation { public Class klazz() { return ArrayDeque.class; } - public Collection emptyCollection() { return new ArrayDeque(); } + public Collection emptyCollection() { return populatedDeque(0); } public Object makeElement(int i) { return i; } public boolean isConcurrent() { return false; } public boolean permitsNulls() { return false; } @@ -39,7 +41,7 @@ public class ArrayDequeTest extends JSR1 * Returns a new deque of given size containing consecutive * Integers 0 ... n - 1. */ - private ArrayDeque populatedDeque(int n) { + private static ArrayDeque populatedDeque(int n) { // Randomize various aspects of memory layout, including // filled-to-capacity and wraparound. final ArrayDeque q; @@ -988,6 +990,25 @@ public class ArrayDequeTest extends JSR1 } /** + * Spliterator characteristics are as advertised + */ + public void testSpliterator_characteristics() { + ArrayDeque q = new ArrayDeque(); + Spliterator s = q.spliterator(); + int characteristics = s.characteristics(); + int required = Spliterator.NONNULL + | Spliterator.ORDERED + | Spliterator.SIZED + | Spliterator.SUBSIZED; + assertEquals(required, characteristics & required); + assertEquals(0, characteristics + & (Spliterator.CONCURRENT + | Spliterator.DISTINCT + | Spliterator.IMMUTABLE + | Spliterator.SORTED)); + } + + /** * Handle capacities near Integer.MAX_VALUE. * ant -Dvmoptions=-Xmx24g -Djsr166.expensiveTests=true -Djsr166.tckTestClass=ArrayDequeTest -Djsr166.methodFilter=testHuge tck */