2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.util;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.assertSame;
14 import static org.junit.Assert.fail;
16 import java.util.NoSuchElementException;
17 import org.junit.Test;
19 public class EmptyDequeTest {
22 public void testEmptyDeque() {
23 final EmptyDeque<?> deque = EmptyDeque.instance();
24 assertFalse(deque.offer(null));
25 assertFalse(deque.offerFirst(null));
26 assertFalse(deque.offerLast(null));
27 assertNull(deque.peek());
28 assertNull(deque.peekFirst());
29 assertNull(deque.peekLast());
30 assertNull(deque.poll());
31 assertNull(deque.pollFirst());
32 assertNull(deque.pollLast());
34 assertEquals(0, deque.size());
35 assertFalse(deque.iterator().hasNext());
36 assertFalse(deque.descendingIterator().hasNext());
37 assertEquals(0L, deque.spliterator().estimateSize());
39 final Object[] a = deque.toArray();
40 assertEquals(0, a.length);
41 assertSame(a, deque.toArray());
42 assertSame(a, deque.toArray(a));
44 assertFalse(deque.removeFirstOccurrence(null));
45 assertFalse(deque.removeLastOccurrence(null));
50 } catch (IllegalStateException e) {
56 } catch (IllegalStateException e) {
62 } catch (IllegalStateException e) {
69 } catch (NoSuchElementException e) {
75 } catch (NoSuchElementException e) {
81 } catch (NoSuchElementException e) {
87 } catch (NoSuchElementException e) {
93 } catch (NoSuchElementException e) {
99 } catch (NoSuchElementException e) {