-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackTest.java
More file actions
77 lines (66 loc) · 1.49 KB
/
StackTest.java
File metadata and controls
77 lines (66 loc) · 1.49 KB
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
70
71
72
73
74
75
76
77
/**
* Universidad del Valle de Guatemala
* Algoritmos y Estructura de Datos
* Sección: 10
* 30/07/2015
* Hoja de Trabajo 2
*
*/
import static org.junit.Assert.*;
import org.junit.Test;
/**
*Esta clase <StackTest> permite realizar pruebas con JUnit
* para comprobar que los métodos de Stack funcionen de manera correcta
*
* @author André Rodas
* @author Rudy Garrido
* @author Yosemite Meléndez
*
*/
public class StackTest {
@Test
public void testIsEmpty() {
Stack<Integer> pruebaStack = new Stack<Integer>();
if (pruebaStack.isEmpty())
assertEquals(0,0,0);
}
@Test
public void testSize() {
Stack<Integer> pruebaStack = new Stack<Integer>();
pruebaStack.push(13);
assertEquals(1,pruebaStack.size(),0);
}
@Test
public void testPop() {
Stack<Integer> pruebaStack = new Stack<Integer>();
pruebaStack.push(13);
try {
assertEquals(13,pruebaStack.pop(),0);
pruebaStack.push(19);
assertEquals(19,pruebaStack.pop(),0);
if (pruebaStack.isEmpty())
assertEquals(0,0,0);
else
assertEquals(10,0,0);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testPeek() {
Stack<Integer> pruebaStack = new Stack<Integer>();
pruebaStack.push(13);
try {
assertEquals(13,pruebaStack.peek(),0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testPush() {
Stack<Integer> pruebaStack = new Stack<Integer>();
pruebaStack.push(13);
assertEquals(1,pruebaStack.size(),0);
}
}