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

Comparing jsr166/src/test/tck/ArrayDequeTest.java (file contents):
Revision 1.43 by jsr166, Mon Oct 17 00:59:53 2016 UTC vs.
Revision 1.47 by jsr166, Mon Oct 17 15:31:19 2016 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
2 > * Written by Doug Lea and Martin Buchholz with assistance from
3 > * members of JCP JSR-166 Expert Group and released to the public
4 > * domain, as explained at
5   * http://creativecommons.org/publicdomain/zero/1.0/
6   */
7  
# Line 13 | Line 14 | import java.util.Iterator;
14   import java.util.NoSuchElementException;
15   import java.util.Queue;
16   import java.util.Random;
17 + import java.util.Spliterator;
18   import java.util.concurrent.ThreadLocalRandom;
19  
20   import junit.framework.Test;
# Line 26 | Line 28 | public class ArrayDequeTest extends JSR1
28      public static Test suite() {
29          class Implementation implements CollectionImplementation {
30              public Class<?> klazz() { return ArrayDeque.class; }
31 <            public Collection emptyCollection() { return new ArrayDeque(); }
31 >            public Collection emptyCollection() { return populatedDeque(0); }
32              public Object makeElement(int i) { return i; }
33              public boolean isConcurrent() { return false; }
34              public boolean permitsNulls() { return false; }
# Line 39 | Line 41 | public class ArrayDequeTest extends JSR1
41       * Returns a new deque of given size containing consecutive
42       * Integers 0 ... n - 1.
43       */
44 <    private ArrayDeque<Integer> populatedDeque(int n) {
44 >    private static ArrayDeque<Integer> populatedDeque(int n) {
45          // Randomize various aspects of memory layout, including
46          // filled-to-capacity and wraparound.
47          final ArrayDeque<Integer> q;
# Line 988 | Line 990 | public class ArrayDequeTest extends JSR1
990      }
991  
992      /**
993 +     * Spliterator characteristics are as advertised
994 +     */
995 +    public void testSpliterator_characteristics() {
996 +        ArrayDeque q = new ArrayDeque();
997 +        Spliterator s = q.spliterator();
998 +        int characteristics = s.characteristics();
999 +        int required = Spliterator.NONNULL
1000 +            | Spliterator.ORDERED
1001 +            | Spliterator.SIZED
1002 +            | Spliterator.SUBSIZED;
1003 +        assertEquals(required, characteristics & required);
1004 +        assertEquals(0, characteristics
1005 +                     & (Spliterator.CONCURRENT
1006 +                        | Spliterator.DISTINCT
1007 +                        | Spliterator.IMMUTABLE
1008 +                        | Spliterator.SORTED));
1009 +    }
1010 +
1011 +    /**
1012 +     * Spliterator.getComparator always throws IllegalStateException
1013 +     */
1014 +    public void testSpliterator_getComparator() {
1015 +        assertThrows(IllegalStateException.class,
1016 +                     () -> new ArrayDeque().spliterator().getComparator());
1017 +    }
1018 +
1019 +    /**
1020       * Handle capacities near Integer.MAX_VALUE.
1021       * ant -Dvmoptions=-Xmx24g -Djsr166.expensiveTests=true -Djsr166.tckTestClass=ArrayDequeTest -Djsr166.methodFilter=testHuge tck
1022       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines