Search in sources :

Example 41 with ArrayDeque

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

the class ArrayDequeTest method testOfferFirst.

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

Example 42 with ArrayDeque

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

the class ArrayDequeTest method testPush.

/**
     * peekFirst() returns element inserted with push
     */
public void testPush() {
    ArrayDeque q = populatedDeque(3);
    q.pollLast();
    q.push(four);
    assertSame(four, q.peekFirst());
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 43 with ArrayDeque

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

the class ArrayDequeTest method testPeek.

/**
     * peek() returns next element, or null if empty
     */
public void testPeek() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.peek());
        assertEquals(i, q.poll());
        assertTrue(q.peek() == null || !q.peek().equals(i));
    }
    assertNull(q.peek());
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 44 with ArrayDeque

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

the class ArrayDequeTest method testToArray_NullArg.

/**
     * toArray(null) throws NullPointerException
     */
public void testToArray_NullArg() {
    ArrayDeque l = new ArrayDeque();
    l.add(new Object());
    try {
        l.toArray(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 45 with ArrayDeque

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

the class ArrayDequeTest method testAddAll2.

/**
     * addAll of a collection with null elements throws NPE
     */
public void testAddAll2() {
    ArrayDeque q = new ArrayDeque();
    try {
        q.addAll(Arrays.asList(new Integer[SIZE]));
        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