forked from billryan/algorithm-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackTest.java
More file actions
33 lines (27 loc) · 697 Bytes
/
StackTest.java
File metadata and controls
33 lines (27 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package basic;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayDeque;
import java.util.Deque;
/**
* @author billryan
* @date 10/8/2019 12:04
*/
public class StackTest {
private static final Logger log = LoggerFactory.getLogger(StackTest.class);
@Test
public void testStack() {
Deque<Integer> stack = new ArrayDeque<>();
stack.push(1);
stack.push(2);
stack.push(3);
int peek = 3;
while (!stack.isEmpty()) {
int stackPeek = stack.pop();
log.info("stack peek: {}", stackPeek);
assert peek == stackPeek;
peek--;
}
}
}