BAEL-1370 Added test to show usage of ArrayDeque. (#3128)

This commit is contained in:
Muhammed Almas 2017-11-25 16:06:23 +05:30 committed by Grzegorz Piwowarek
parent 6435d5723a
commit 04dc60bd12
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
package com.baeldung.arraydeque;
import java.util.ArrayDeque;
import java.util.Deque;
import static org.junit.Assert.*;
import org.junit.Test;
public class ArrayDequeTest {
@Test
public void whenOffer_addsAtLast() {
final Deque<String> deque = new ArrayDeque<>();
deque.offer("first");
deque.offer("second");
assertEquals("second", deque.getLast());
}
@Test
public void whenPoll_removesFirst() {
final Deque<String> deque = new ArrayDeque<>();
deque.offer("first");
deque.offer("second");
assertEquals("first", deque.poll());
}
@Test
public void whenPush_addsAtFirst() {
final Deque<String> deque = new ArrayDeque<>();
deque.push("first");
deque.push("second");
assertEquals("second", deque.getFirst());
}
@Test
public void whenPop_removesLast() {
final Deque<String> deque = new ArrayDeque<>();
deque.push("first");
deque.push("second");
assertEquals("second", deque.pop());
}
}