Search in sources :

Example 51 with ArrayDeque

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

the class ArrayDequeTest method testOfferLast.

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

Example 52 with ArrayDeque

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

the class ArrayDequeTest method testAddNull.

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

Example 53 with ArrayDeque

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

the class ArrayDequeTest method testPoll.

/**
     * poll() succeeds unless empty
     */
public void testPoll() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.poll());
    }
    assertNull(q.poll());
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 54 with ArrayDeque

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

the class ArrayDequeTest method testContains.

/**
     * contains(x) reports true when elements added but not yet removed
     */
public void testContains() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.contains(new Integer(i)));
        assertEquals(i, q.pollFirst());
        assertFalse(q.contains(new Integer(i)));
    }
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 55 with ArrayDeque

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

the class ArrayDequeTest method testContainsAll.

/**
     * containsAll(c) is true when c contains a subset of elements
     */
public void testContainsAll() {
    ArrayDeque q = populatedDeque(SIZE);
    ArrayDeque p = new ArrayDeque();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.containsAll(p));
        assertFalse(p.containsAll(q));
        assertTrue(p.add(new Integer(i)));
    }
    assertTrue(p.containsAll(q));
}
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