mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
9bb3d6b972
git-subtree-dir: sgx-jvm/avian git-subtree-mainline:f978eab8d1
git-subtree-split:09e4fe60d0
56 lines
1.4 KiB
Java
56 lines
1.4 KiB
Java
import java.util.Deque;
|
|
|
|
public class DequeHelper {
|
|
private static void verify(boolean val) {
|
|
if (! val) {
|
|
throw new RuntimeException();
|
|
}
|
|
}
|
|
|
|
public static void main(String args[]) {
|
|
// prevents unit test failure
|
|
}
|
|
|
|
public static void addFirstTest(Deque<Object> q) {
|
|
Object firstObject = new Object();
|
|
Object lastObject = new Object();
|
|
q.addFirst(lastObject);
|
|
q.addFirst(firstObject);
|
|
|
|
verify(q.size() == 2);
|
|
verify(q.peekFirst() == firstObject);
|
|
verify(q.peekLast() == lastObject);
|
|
}
|
|
|
|
public static void addLastTest(Deque<Object> q) {
|
|
Object firstObject = new Object();
|
|
Object lastObject = new Object();
|
|
q.addLast(firstObject);
|
|
q.addLast(lastObject);
|
|
|
|
verify(q.size() == 2);
|
|
verify(q.peekFirst() == firstObject);
|
|
verify(q.peekLast() == lastObject);
|
|
}
|
|
|
|
public static void removeFirstTest(Deque<Object> q) {
|
|
Object firstObject = new Object();
|
|
Object lastObject = new Object();
|
|
q.addLast(firstObject);
|
|
q.addLast(lastObject);
|
|
|
|
verify(q.removeFirst() == firstObject);
|
|
verify(q.removeFirst() == lastObject);
|
|
}
|
|
|
|
public static void removeLastTest(Deque<Object> q) {
|
|
Object firstObject = new Object();
|
|
Object lastObject = new Object();
|
|
q.addLast(firstObject);
|
|
q.addLast(lastObject);
|
|
|
|
verify(q.removeLast() == lastObject);
|
|
verify(q.removeLast() == firstObject);
|
|
}
|
|
}
|