-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestStack.java
More file actions
57 lines (36 loc) · 1022 Bytes
/
TestStack.java
File metadata and controls
57 lines (36 loc) · 1022 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package TetsStructures;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import Stack.Stack;
class TestStack {
private Stack<Integer> stack;
private void stageOne() {
stack = new Stack<Integer>();
}
@Test
void test() {
stageOne();
assertTrue(stack.isEmpty());
assertTrue(stack.getSize() == 0);
stack.push(73);
stack.push(37);
stack.push(65);
stack.push(21);
stack.push(98);
assertTrue(stack.getSize() == 5);
assertFalse(stack.isEmpty());
assertTrue( stack.topElement().getValue() == 98);
stack.pop();
assertTrue( stack.topElement().getValue() == 21);
stack.pop();
assertTrue( stack.topElement().getValue() == 65);
stack.pop();
assertTrue( stack.topElement().getValue() == 37);
stack.pop();
assertTrue( stack.topElement().getValue() == 73);
stack.pop();
assertTrue(stack.isEmpty());
assertTrue(stack.getSize() == 0);
}
}