/** @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);
  }
  /**
   * @param q Deque.
   * @param expSize Expected size.
   */
  @SuppressWarnings({"ForLoopReplaceableByForEach"})
  private <T> void checkSize(ConcurrentLinkedDeque8<T> q, int expSize) {
    int actualSize = 0;

    for (Iterator<T> iter = q.iterator(); iter.hasNext(); ) {
      iter.next();

      actualSize++;
    }

    assertEquals(expSize, actualSize);

    actualSize = 0;

    for (Iterator<T> iter = q.iterator(); iter.hasNext(); ) {
      iter.next();

      actualSize++;
    }

    assertEquals(expSize, actualSize);

    assertEquals(expSize, q.size());

    assertEquals(expSize, q.sizex());

    if (expSize > 0) {
      assert !q.isEmpty();

      assert !q.isEmptyx();
    } else {
      assert q.isEmpty();

      assert q.isEmptyx();
    }
  }