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; } |
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; |
988 |
|
} |
989 |
|
} |
990 |
|
|
991 |
– |
/** |
992 |
– |
* Handle capacities near Integer.MAX_VALUE. |
993 |
– |
* ant -Dvmoptions=-Xmx24g -Djsr166.expensiveTests=true -Djsr166.tckTestClass=ArrayDequeTest -Djsr166.methodFilter=testHuge tck |
994 |
– |
*/ |
995 |
– |
public void testHuge() { |
996 |
– |
if (! (testImplementationDetails |
997 |
– |
&& expensiveTests |
998 |
– |
&& Runtime.getRuntime().freeMemory() > 21_000_000_000L)) |
999 |
– |
return; |
1000 |
– |
int maxSize = Integer.MAX_VALUE - 8; |
1001 |
– |
ArrayDeque<Integer> q; |
1002 |
– |
|
1003 |
– |
q = new ArrayDeque<>(maxSize); |
1004 |
– |
|
1005 |
– |
assertThrows(OutOfMemoryError.class, |
1006 |
– |
() -> new ArrayDeque<>(Integer.MAX_VALUE)); |
1007 |
– |
|
1008 |
– |
q = populatedDeque(0); |
1009 |
– |
q.addAll(Collections.nCopies(maxSize - 2, (Integer) 42)); |
1010 |
– |
assertEquals((Integer) 42, q.peekFirst()); |
1011 |
– |
assertEquals((Integer) 42, q.peekLast()); |
1012 |
– |
assertEquals(maxSize - 2, q.size()); |
1013 |
– |
q.addFirst((Integer) 0); |
1014 |
– |
q.addLast((Integer) 1); |
1015 |
– |
assertEquals((Integer) 0, q.peekFirst()); |
1016 |
– |
assertEquals((Integer) 1, q.peekLast()); |
1017 |
– |
assertEquals(maxSize, q.size()); |
1018 |
– |
} |
1019 |
– |
|
991 |
|
} |