File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 6
6
public class StackTestCase {
7
7
8
8
@ Test
9
- public void test_stack_push () {
9
+ public void testStackPush () {
10
10
Stack newStack = new Stack ();
11
+ assertEquals (0 , newStack .count ());
11
12
newStack .push (100 );
13
+ assertEquals (1 , newStack .count ());
12
14
assertFalse (newStack .empty );
13
15
}
14
16
15
17
@ Test
18
+ public void testStackPopRemovesAndReturnsLastItemIn () {
19
+ Stack newStack = new Stack ();
20
+ newStack .push (1 );
21
+ newStack .push (2 );
22
+ newStack .push (3 );
23
+ assertEquals (3 , newStack .count ());
24
+ Object item = newStack .pop ();
25
+ assertEquals (2 , newStack .count ());
26
+ assertEquals (3 , item );
27
+ }
28
+
29
+ @ Test
30
+ public void testStackPeek () {
31
+ Stack newStack = new Stack ();
32
+ newStack .push (1 );
33
+ newStack .push (2 );
34
+ assertEquals (2 , newStack .peek ());
35
+ }
16
36
}
You can’t perform that action at this time.
0 commit comments