test/jdk/java/util/ArrayDeque/WhiteBox.java
author dl
Tue, 10 Jul 2018 10:24:08 -0700
changeset 50959 f9b96afb7c5e
permissions -rw-r--r--
8206123: ArrayDeque created with default constructor can only hold 15 elements Reviewed-by: martin, psandoz, igerasim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50959
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     1
/*
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     3
 *
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     6
 * published by the Free Software Foundation.
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     7
 *
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    12
 * accompanied this code).
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    13
 *
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    17
 *
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    20
 * questions.
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    21
 */
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    22
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    23
/*
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    24
 * This file is available under and governed by the GNU General Public
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    25
 * License version 2 only, as published by the Free Software Foundation.
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    26
 * However, the following notice accompanied the original version of this
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    27
 * file:
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    28
 *
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    29
 * Written by Martin Buchholz with assistance from members of JCP
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    30
 * JSR-166 Expert Group and released to the public domain, as
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    31
 * explained at http://creativecommons.org/publicdomain/zero/1.0/
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    32
 */
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    33
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    34
/*
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    35
 * @test
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    36
 * @modules java.base/java.util:open
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    37
 * @run testng WhiteBox
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    38
 * @summary White box tests of implementation details
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    39
 */
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    40
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    41
import static org.testng.Assert.*;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    42
import org.testng.annotations.Test;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    43
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    44
import java.io.ByteArrayInputStream;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    45
import java.io.ByteArrayOutputStream;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    46
import java.io.ObjectInputStream;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    47
import java.io.ObjectOutputStream;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    48
import java.lang.invoke.MethodHandles;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    49
import java.lang.invoke.VarHandle;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    50
import java.util.ArrayDeque;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    51
import java.util.concurrent.ThreadLocalRandom;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    52
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    53
@Test
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    54
public class WhiteBox {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    55
    final ThreadLocalRandom rnd = ThreadLocalRandom.current();
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    56
    final VarHandle ELEMENTS, HEAD, TAIL;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    57
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    58
    WhiteBox() throws ReflectiveOperationException {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    59
        Class<?> klazz = ArrayDeque.class;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    60
        MethodHandles.Lookup lookup
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    61
            = MethodHandles.privateLookupIn(klazz, MethodHandles.lookup());
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    62
        ELEMENTS = lookup.findVarHandle(klazz, "elements", Object[].class);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    63
        HEAD = lookup.findVarHandle(klazz, "head", int.class);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    64
        TAIL = lookup.findVarHandle(klazz, "tail", int.class);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    65
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    66
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    67
    Object[] elements(ArrayDeque d) { return (Object[]) ELEMENTS.get(d); }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    68
    int head(ArrayDeque d) { return (int) HEAD.get(d); }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    69
    int tail(ArrayDeque d) { return (int) TAIL.get(d); }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    70
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    71
    void checkCapacity(ArrayDeque d, int capacity) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    72
        assertTrue(d.isEmpty());
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    73
        assertEquals(0, head(d));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    74
        assertEquals(0, tail(d));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    75
        Object[] initialElements = elements(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    76
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    77
        assertInvariants(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    78
        for (int i = capacity; i--> 0; ) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    79
            d.add(rnd.nextInt(42));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    80
            assertSame(elements(d), initialElements);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    81
            assertInvariants(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    82
        }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    83
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    84
        d.add(rnd.nextInt(42));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    85
        assertNotSame(elements(d), initialElements);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    86
        assertInvariants(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    87
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    88
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    89
    @Test
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    90
    public void defaultConstructor() {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    91
        checkCapacity(new ArrayDeque(), 16);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    92
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    93
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    94
    @Test
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    95
    public void shouldNotResizeWhenInitialCapacityProvided() {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    96
        int initialCapacity = rnd.nextInt(20);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    97
        checkCapacity(new ArrayDeque(initialCapacity), initialCapacity);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    98
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
    99
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   100
    byte[] serialBytes(Object o) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   101
        try {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   102
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   103
            ObjectOutputStream oos = new ObjectOutputStream(bos);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   104
            oos.writeObject(o);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   105
            oos.flush();
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   106
            oos.close();
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   107
            return bos.toByteArray();
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   108
        } catch (Exception fail) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   109
            throw new AssertionError(fail);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   110
        }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   111
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   112
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   113
    @SuppressWarnings("unchecked")
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   114
    <T> T serialClone(T o) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   115
        try {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   116
            ObjectInputStream ois = new ObjectInputStream
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   117
                (new ByteArrayInputStream(serialBytes(o)));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   118
            T clone = (T) ois.readObject();
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   119
            assertNotSame(o, clone);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   120
            assertSame(o.getClass(), clone.getClass());
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   121
            return clone;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   122
        } catch (Exception fail) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   123
            throw new AssertionError(fail);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   124
        }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   125
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   126
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   127
    @Test
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   128
    public void testSerialization() {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   129
        ArrayDeque[] ds = { new ArrayDeque(), new ArrayDeque(rnd.nextInt(20)) };
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   130
        for (ArrayDeque d : ds) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   131
            if (rnd.nextBoolean()) d.add(99);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   132
            ArrayDeque clone = serialClone(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   133
            assertInvariants(clone);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   134
            assertNotSame(elements(d), elements(clone));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   135
            assertEquals(d, clone);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   136
        }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   137
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   138
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   139
    /** Checks conditions which should always be true. */
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   140
    void assertInvariants(ArrayDeque d) {
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   141
        final Object[] elements = elements(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   142
        final int head = head(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   143
        final int tail = tail(d);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   144
        final int capacity = elements.length;
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   145
        assertTrue(0 <= head && head < capacity);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   146
        assertTrue(0 <= tail && tail < capacity);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   147
        assertTrue(capacity > 0);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   148
        assertTrue(d.size() < capacity);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   149
        assertTrue((head == tail) ^ (elements[head] != null));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   150
        assertNull(elements[tail]);
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   151
        assertTrue((head == tail) ^ (elements[Math.floorMod(tail - 1, capacity)] != null));
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   152
    }
f9b96afb7c5e 8206123: ArrayDeque created with default constructor can only hold 15 elements
dl
parents:
diff changeset
   153
}