Search in sources :

Example 36 with ArrayDeque

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

the class ArrayDequeTest method testRemoveFirst.

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

Example 37 with ArrayDeque

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

the class ArrayDequeTest method testEmptyIterator.

/**
     * iterator of empty collection has no elements
     */
public void testEmptyIterator() {
    Deque c = new ArrayDeque();
    assertIteratorExhausted(c.iterator());
    assertIteratorExhausted(c.descendingIterator());
}
Also used : ArrayDeque(java.util.ArrayDeque) Deque(java.util.Deque) ArrayDeque(java.util.ArrayDeque)

Example 38 with ArrayDeque

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

the class ArrayDequeTest method testClear.

/**
     * clear removes all elements
     */
public void testClear() {
    ArrayDeque q = populatedDeque(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    assertTrue(q.add(new Integer(1)));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 39 with ArrayDeque

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

the class ArrayDequeTest method testPollLast.

/**
     * pollLast() succeeds unless empty
     */
public void testPollLast() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = SIZE - 1; i >= 0; --i) {
        assertEquals(i, q.pollLast());
    }
    assertNull(q.pollLast());
}
Also used : ArrayDeque(java.util.ArrayDeque)

Example 40 with ArrayDeque

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

the class ArrayDequeTest method testAddLastNull.

/**
     * addLast(null) throws NPE
     */
public void testAddLastNull() {
    ArrayDeque q = new ArrayDeque();
    try {
        q.addLast(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