use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.
the class ConcurrentLinkedDequeTest method testWeaklyConsistentIteration.
/**
* Modifications do not cause iterators to fail
*/
public void testWeaklyConsistentIteration() {
final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
q.add(one);
q.add(two);
q.add(three);
for (Iterator it = q.iterator(); it.hasNext(); ) {
q.remove();
it.next();
}
assertEquals("deque should be empty again", 0, q.size());
}
use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.
the class ConcurrentLinkedDequeTest method testPollFirst.
/**
* pollFirst() succeeds unless empty
*/
public void testPollFirst() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.pollFirst());
}
assertNull(q.pollFirst());
}
use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.
the class ConcurrentLinkedDequeTest method testAddAllSelf.
/**
* addAll(this) throws IAE
*/
public void testAddAllSelf() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
try {
q.addAll(q);
shouldThrow();
} catch (IllegalArgumentException success) {
}
}
use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.
the class ConcurrentLinkedDequeTest method testPeek.
/**
* peek() returns next element, or null if empty
*/
public void testPeek() {
ConcurrentLinkedDeque 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());
}
use of java.util.concurrent.ConcurrentLinkedDeque in project j2objc by google.
the class ConcurrentLinkedDequeTest method testDescendingIterator.
/**
* Descending iterator iterates through all elements
*/
public void testDescendingIterator() {
ConcurrentLinkedDeque q = populatedDeque(SIZE);
int i = 0;
Iterator it = q.descendingIterator();
while (it.hasNext()) {
assertTrue(q.contains(it.next()));
++i;
}
assertEquals(i, SIZE);
assertFalse(it.hasNext());
try {
it.next();
shouldThrow();
} catch (NoSuchElementException success) {
}
}
Aggregations