@@ -115,7 +115,7 @@ class StackTest {
115
115
116
116
@ Test
117
117
@ DisplayName ("List Stack에 데이터 5개 넣고 뺴기" )
118
- void listStack에_데이터_5개_넣고_빼기 () {
118
+ void ListStack에_데이터_5개_넣고_빼기 () {
119
119
Stack <Integer > stack = new ListStack <>();
120
120
121
121
stack .push (1 );
@@ -140,4 +140,70 @@ class StackTest {
140
140
assertThat (stack .isEmpty ()).isTrue ();
141
141
assertThat (stack .size ()).isEqualTo (0 );
142
142
}
143
+
144
+ @ Test
145
+ @ DisplayName ("CircularList Stack의 생성 및 초기화" )
146
+ void circularListStack의_생성_및_초기화 () {
147
+ Stack <Integer > stack = new CircularListStack <>();
148
+
149
+ assertThat (stack ).isNotNull ();
150
+ assertThat (stack .isEmpty ()).isTrue ();
151
+ assertThat (stack .size ()).isEqualTo (0 );
152
+ }
153
+
154
+ @ Test
155
+ @ DisplayName ("CircularList Stack의 EmptyStackException 테스트" )
156
+ void circularListStack의_EmptyStackException_테스트 () {
157
+ Stack <Integer > stack = new CircularListStack <>();
158
+
159
+ assertThat (stack ).isNotNull ();
160
+ assertThat (stack .isEmpty ()).isTrue ();
161
+ assertThat (stack .size ()).isEqualTo (0 );
162
+ assertThatThrownBy (stack ::pop ).isInstanceOf (EmptyStackException .class );
163
+ assertThatThrownBy (stack ::peek ).isInstanceOf (EmptyStackException .class );
164
+ }
165
+
166
+ @ Test
167
+ @ DisplayName ("CircularList Stack에 데이터 5개 넣기" )
168
+ void circularListStack에_데이터_5개_넣기 () {
169
+ Stack <Integer > stack = new CircularListStack <>();
170
+
171
+ stack .push (1 );
172
+ stack .push (2 );
173
+ stack .push (3 );
174
+ stack .push (4 );
175
+ stack .push (5 );
176
+
177
+ assertThat (stack ).isNotNull ();
178
+ assertThat (stack .isEmpty ()).isFalse ();
179
+ assertThat (stack .size ()).isEqualTo (5 );
180
+ }
181
+
182
+ @ Test
183
+ @ DisplayName ("CircularList Stack에 데이터 5개 넣고 뺴기" )
184
+ void circularListStack에_데이터_5개_넣고_빼기 () {
185
+ Stack <Integer > stack = new CircularListStack <>();
186
+
187
+ stack .push (1 );
188
+ stack .push (2 );
189
+ stack .push (3 );
190
+ stack .push (4 );
191
+ stack .push (5 );
192
+
193
+ assertThat (stack ).isNotNull ();
194
+ assertThat (stack .isEmpty ()).isFalse ();
195
+ assertThat (stack .size ()).isEqualTo (5 );
196
+ assertThat (stack .peek ()).isEqualTo (5 );
197
+ assertThat (stack .pop ()).isEqualTo (5 );
198
+ assertThat (stack .peek ()).isEqualTo (4 );
199
+ assertThat (stack .pop ()).isEqualTo (4 );
200
+ assertThat (stack .peek ()).isEqualTo (3 );
201
+ assertThat (stack .pop ()).isEqualTo (3 );
202
+ assertThat (stack .peek ()).isEqualTo (2 );
203
+ assertThat (stack .pop ()).isEqualTo (2 );
204
+ assertThat (stack .peek ()).isEqualTo (1 );
205
+ assertThat (stack .pop ()).isEqualTo (1 );
206
+ assertThat (stack .isEmpty ()).isTrue ();
207
+ assertThat (stack .size ()).isEqualTo (0 );
208
+ }
143
209
}
0 commit comments