Search in sources :

Example 46 with ArrayDeque

use of java.util.ArrayDeque in project mapdb by jankotek.

the class ArrayDequeTest method testRemove.

/**
     * remove() removes next element, or throws NSEE if empty
     */
public void testRemove() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.remove());
    }
    try {
        q.remove();
        shouldThrow();
    } catch (NoSuchElementException success) {
    }
}
Also used : ArrayDeque(java.util.ArrayDeque) NoSuchElementException(java.util.NoSuchElementException)

Example 47 with ArrayDeque

use of java.util.ArrayDeque in project mapdb by jankotek.

the class ArrayDequeTest method testAddLast.

/**
     * addLast(x) succeeds
     */
public void testAddLast() {
    ArrayDeque q = new ArrayDeque();
    q.addLast(zero);
    q.addLast(one);
    assertSame(zero, q.peekFirst());
    assertSame(one, q.peekLast());
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 48 with ArrayDeque

use of java.util.ArrayDeque in project mapdb by jankotek.

the class ArrayDequeTest method testOfferNull.

/**
     * offer(null) throws NPE
     */
public void testOfferNull() {
    ArrayDeque q = new ArrayDeque();
    try {
        q.offer(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 49 with ArrayDeque

use of java.util.ArrayDeque in project mapdb by jankotek.

the class ArrayDequeTest method testDescendingIteratorOrdering.

/**
     * Descending iterator ordering is reverse FIFO
     */
public void testDescendingIteratorOrdering() {
    final ArrayDeque q = new ArrayDeque();
    for (int iters = 0; iters < 100; ++iters) {
        q.add(new Integer(3));
        q.add(new Integer(2));
        q.add(new Integer(1));
        int k = 0;
        for (Iterator it = q.descendingIterator(); it.hasNext(); ) {
            assertEquals(++k, it.next());
        }
        assertEquals(3, k);
        q.remove();
        q.remove();
        q.remove();
    }
}
Also used : Iterator(java.util.Iterator) ArrayDeque(java.util.ArrayDeque)

Example 50 with ArrayDeque

use of java.util.ArrayDeque in project mapdb by jankotek.

the class ArrayDequeTest method testOfferFirstNull.

/**
     * offerFirst(null) throws NPE
     */
public void testOfferFirstNull() {
    ArrayDeque q = new ArrayDeque();
    try {
        q.offerFirst(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ArrayDeque(java.util.ArrayDeque)

Aggregations

ArrayDeque (java.util.ArrayDeque)217 ArrayList (java.util.ArrayList)36 Test (org.junit.Test)36 IOException (java.io.IOException)27 HashMap (java.util.HashMap)23 List (java.util.List)20 HashSet (java.util.HashSet)19 Map (java.util.Map)17 Deque (java.util.Deque)11 Iterator (java.util.Iterator)10 NoSuchElementException (java.util.NoSuchElementException)8 AtomicLong (java.util.concurrent.atomic.AtomicLong)8 File (java.io.File)7 Path (java.nio.file.Path)7 Random (java.util.Random)7 ByteBuffer (java.nio.ByteBuffer)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 HttpFields (org.eclipse.jetty.http.HttpFields)5 Name (com.github.anba.es6draft.ast.scope.Name)4 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)4