/** @throws Exception If failed. */
  public void testPoll() throws Exception {
    ConcurrentLinkedDeque8<Integer> deque = new ConcurrentLinkedDeque8<>();

    deque.add(1);
    deque.add(2);
    deque.add(3);

    assert !deque.isEmpty();

    checkSize(deque, 3);

    // Poll 1.
    assertEquals(Integer.valueOf(1), deque.poll());

    assert !deque.isEmpty();

    checkSize(deque, 2);

    // Poll 2.
    assertEquals(Integer.valueOf(2), deque.poll());

    assert !deque.isEmpty();

    checkSize(deque, 1);

    // Poll 3.
    assertEquals(Integer.valueOf(3), deque.poll());

    assert deque.isEmpty();

    checkSize(deque, 0);
  }
  public void testUnlinkWithIterator() {
    ConcurrentLinkedDeque8<Integer> q = new ConcurrentLinkedDeque8<>();

    q.add(1);
    Node<Integer> n2 = q.addx(2);
    Node<Integer> n3 = q.addx(3);
    Node<Integer> n4 = q.addx(4);
    Node<Integer> n5 = q.addx(5);
    q.add(6);

    Iterator<Integer> it = q.iterator();

    assertTrue(it.hasNext());
    assertEquals(1, it.next().intValue());

    assertTrue(it.hasNext());
    assertEquals(2, it.next().intValue());

    assertTrue(it.hasNext());
    assertEquals(3, it.next().intValue());

    q.unlinkx(n2);
    q.unlinkx(n3);
    q.unlinkx(n4);
    q.unlinkx(n5);

    assertTrue(it.hasNext());
    assertEquals(4, it.next().intValue());

    assertTrue(it.hasNext());
    assertEquals(6, it.next().intValue());
  }
  public void testUnlinkLastWithIterator() {
    ConcurrentLinkedDeque8<Integer> q = new ConcurrentLinkedDeque8<>();

    q.add(1);
    q.addx(2);
    Node<Integer> n3 = q.addx(3);

    Iterator<Integer> it = q.iterator();

    assertTrue(it.hasNext());
    assertEquals(1, it.next().intValue());

    q.unlinkx(n3);

    assertTrue(it.hasNext());
    assertEquals(2, it.next().intValue());

    assertFalse(it.hasNext());
  }