-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCellStackTests.java
69 lines (56 loc) · 1.84 KB
/
CellStackTests.java
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
58
59
60
61
62
63
64
65
66
67
68
69
public class CellStackTests {
public static void main(String[] args){
// case 1: Constructor
{
// setup
CellStack stack = new CellStack();
// verify
System.out.println(stack);
// test
assert stack != null : "Error in CellStack::CellStack()";
}
// case 2: push()
{
// setup
CellStack stack = new CellStack();
for(int i = 0; i < 5; i++){
stack.push(new Cell());
}
// verify
System.out.println(stack.size() + " == 5");
// test
assert stack.size() == 5 : "Error in CellStack::push()";
}
// case 3: peek()
{
// setup
CellStack stack = new CellStack();
for(int i = 1; i < 5; i++){
stack.push(new Cell(i, i, i));
}
Cell peek = stack.peek();
// verify
System.out.println(peek.getValue() + " == 4");
System.out.println(stack.size() + " == 4");
// test
assert peek.getValue() == 4 : "Error in CellStack::peek()";
assert stack.size() == 4 : "Error in CellStack::peek()";
}
// case 4: pop()
{
// setup
CellStack stack = new CellStack();
for(int i = 1; i < 5; i++){
stack.push(new Cell(i, i, i));
}
Cell pop = stack.pop();
// verify
System.out.println(pop.getValue() + " == 4");
System.out.println(stack.size() + " == 3");
System.out.println(stack);
// test
assert pop.getValue() == 4 : "Error in CellStack::pop()";
assert stack.size() == 3 : "Error in CellStack::pop()";
}
}
}