-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackTest.java
More file actions
141 lines (99 loc) · 1.91 KB
/
stackTest.java
File metadata and controls
141 lines (99 loc) · 1.91 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package stack1;
import static org.junit.Assert.*;
import javax.lang.model.type.DeclaredType;
import org.junit.Before;
import org.junit.Test;
public class stackTest {
Stack s;
@Before
public void initialize() {
s = new Stack();
}
@Test
public void testGetSize() {
s.push(-2);
s.push(5);
assertEquals(2, s.getSize());
}
@Test
public void testToArray() {
s.push(888);
s.push(101);
s.push(111);
int expected[] = {111,101,888};
assertArrayEquals(expected, s.toArray());
}
@Test
public void testPushInt() {
s.push(5);
s.push(-23);
assertEquals(-23, s.head.getData());
assertEquals(5, s.head.next.getData());
}
@Test
public void testPop() {
s.push(3);
s.push(5015);
s.push(654555);
assertEquals(654555, s.kick());
assertEquals(5015, s.kick());
assertEquals(3, s.kick());
}
@Test
public void testPushArray() {
int s_data[] = {997,21};
s.push(s_data[0]);
s.push(s_data[1]);
assertEquals(21, s.head.getData());
assertEquals(997, s.head.next.getData());
}
@Test
public void testRemoveItem() {
s.push(81);
s.push(71);
s.push(51);
s.removeItem(71);
s.removeItem(51);
assertEquals(81, s.head.getData());
s.push(100);
s.removeItem(81);
assertEquals(100, s.head.getData());
}
@Test
public void testIsEmpty() {
assertTrue(s.isEmpty());
s.push(3);
assertFalse( s.isEmpty());
}
@Test
public void testJoin() {
s.push(1);
s.push(0);
String sptor = "";
assertEquals("0,1", s.join(""));
s.push(1);
s.push(0);
s.push(1);
s.push(0);
sptor = "&";
assertEquals("0&1&0&1", s.join("&"));
}
@Test
public void testDump() {
}
@Test
public void testUnique()
{
s.push(1);
s.push(1);
s.push(8);
s.push(6);
s.push(6);
s.push(10);
s.push(8);
assertEquals("8 10 6 1 ", s.unique());
s.push(11);
s.push(6);
assertEquals("6 11 ", s.unique());
}
}