Skip to content

Commit d71b421

Browse files
committed
test: peek과 pop이 예외를 발생시키는지 테스트하는 코드 추가
1 parent 71f154f commit d71b421

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

yoonexample/src/test/java/stack/StackTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package stack;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
45

6+
import java.util.EmptyStackException;
57
import org.junit.jupiter.api.DisplayName;
68
import org.junit.jupiter.api.Test;
79

@@ -17,6 +19,18 @@ class StackTest {
1719
assertThat(stack.size()).isEqualTo(0);
1820
}
1921

22+
@Test
23+
@DisplayName("Array Stack의 EmptyStackException 테스트")
24+
void arrayStack의_EmptyStackException_테스트() {
25+
Stack<Integer> stack = new ArrayStack<>();
26+
27+
assertThat(stack).isNotNull();
28+
assertThat(stack.isEmpty()).isTrue();
29+
assertThat(stack.size()).isEqualTo(0);
30+
assertThatThrownBy(stack::pop).isInstanceOf(EmptyStackException.class);
31+
assertThatThrownBy(stack::peek).isInstanceOf(EmptyStackException.class);
32+
}
33+
2034
@Test
2135
@DisplayName("Array Stack에 데이터 5개 넣기")
2236
void arrayStack에_데이터_5개_넣기() {

0 commit comments

Comments
 (0)