File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
test/dataStructures/stack Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ package test .dataStructures .stack ;
2
+
3
+ import org .junit .Assert ;
4
+ import org .junit .Test ;
5
+ import src .dataStructures .stack .Stack ;
6
+ public class StackTest {
7
+ @ Test
8
+ public void testEmpty (){
9
+ Stack <Integer > stk = new Stack <>();
10
+ Assert .assertEquals (stk .pop (), null );
11
+ Assert .assertEquals (stk .peek (), null );
12
+ }
13
+
14
+ @ Test
15
+ public void testPopAndPeek () {
16
+ Stack <Integer > stk = new Stack <>(1 , 2 , 3 );
17
+ Assert .assertEquals (stk .peek ().toString (), "3" );
18
+ Assert .assertEquals (stk .pop ().toString (), "3" );
19
+ Assert .assertEquals (stk .peek ().toString (), "2" );
20
+ }
21
+
22
+ @ Test
23
+ public void testPush () {
24
+ Stack <Integer > stk = new Stack <>();
25
+ stk .push (1 );
26
+ Assert .assertEquals (stk .peek ().toString (), "1" );
27
+ stk .push (2 );
28
+ stk .push (3 );
29
+ Assert .assertEquals (stk .peek ().toString (), "3" );
30
+ }
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments