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.51 by jsr166, Tue Oct 25 01:32:55 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 26 | Line 27 | public class ArrayDequeTest extends JSR1
27      public static Test suite() {
28          class Implementation implements CollectionImplementation {
29              public Class<?> klazz() { return ArrayDeque.class; }
30 <            public Collection emptyCollection() { return new ArrayDeque(); }
30 >            public Collection emptyCollection() { return populatedDeque(0); }
31              public Object makeElement(int i) { return i; }
32              public boolean isConcurrent() { return false; }
33              public boolean permitsNulls() { return false; }
# Line 39 | Line 40 | public class ArrayDequeTest extends JSR1
40       * Returns a new deque of given size containing consecutive
41       * Integers 0 ... n - 1.
42       */
43 <    private ArrayDeque<Integer> populatedDeque(int n) {
43 >    private static ArrayDeque<Integer> populatedDeque(int n) {
44          // Randomize various aspects of memory layout, including
45          // filled-to-capacity and wraparound.
46          final ArrayDeque<Integer> q;
# Line 987 | Line 988 | public class ArrayDequeTest extends JSR1
988          }
989      }
990  
990    /**
991     * Handle capacities near Integer.MAX_VALUE.
992     * ant -Dvmoptions=-Xmx24g -Djsr166.expensiveTests=true -Djsr166.tckTestClass=ArrayDequeTest -Djsr166.methodFilter=testHuge tck
993     */
994    public void testHuge() {
995        if (! (testImplementationDetails
996               && expensiveTests
997               && Runtime.getRuntime().freeMemory() > 21_000_000_000L))
998            return;
999        int maxSize = Integer.MAX_VALUE - 8;
1000        ArrayDeque<Integer> q;
1001
1002        q = new ArrayDeque<>(maxSize);
1003
1004        assertThrows(OutOfMemoryError.class,
1005                     () -> new ArrayDeque<>(Integer.MAX_VALUE));
1006
1007        q = populatedDeque(0);
1008        q.addAll(Collections.nCopies(maxSize - 2, (Integer) 42));
1009        assertEquals((Integer) 42, q.peekFirst());
1010        assertEquals((Integer) 42, q.peekLast());
1011        assertEquals(maxSize - 2, q.size());
1012        q.addFirst((Integer) 0);
1013        q.addLast((Integer) 1);
1014        assertEquals((Integer) 0, q.peekFirst());
1015        assertEquals((Integer) 1, q.peekLast());
1016        assertEquals(maxSize, q.size());
1017    }
1018
991   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines