corda/sgx-jvm/avian/test/DequeHelper.java
Andras Slemmer 9bb3d6b972 Add 'sgx-jvm/avian/' from commit '09e4fe60d01f4f4bfb6b2976973bb4913ef61edc'
git-subtree-dir: sgx-jvm/avian
git-subtree-mainline: f978eab8d1
git-subtree-split: 09e4fe60d0
2017-03-13 12:18:24 +00:00

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);
}
}