Skip to content

Commit 582571d

Browse files
committed
test: 중위 표기법으로 작성된 수식을 계산하는 테스트 추가
1 parent a1381fa commit 582571d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package stack;
2+
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.DisplayName;
5+
import org.junit.jupiter.api.Test;
6+
7+
class InfixCalculatorTest {
8+
9+
InfixCalculator infixCalculator;
10+
11+
@BeforeEach
12+
void setUp() {
13+
infixCalculator = new InfixCalculator();
14+
}
15+
16+
@Test
17+
@DisplayName("중위_표기법으로_작성된_수식_계산_테스트1")
18+
void 중위_표기법으로_작성된_수식_계산_테스트1() {
19+
String input = "1 + 2 * 3";
20+
21+
assertThat(infixCalculator.calculate(input)).isEqualTo(7);
22+
}
23+
24+
@Test
25+
@DisplayName("중위_표기법으로_작성된_수식_계산_테스트2")
26+
void 중위_표기법으로_작성된_수식_계산_테스트2() {
27+
String input = "(1 + 2) * 3";
28+
29+
assertThat(infixCalculator.calculate(input)).isEqualTo(9);
30+
}
31+
32+
@Test
33+
@DisplayName("중위_표기법으로_작성된_수식_계산_테스트3")
34+
void 중위_표기법으로_작성된_수식_계산_테스트3() {
35+
String input = "((1 - 2) + 3) * (5 - 2)";
36+
37+
assertThat(infixCalculator.calculate(input)).isEqualTo(6);
38+
}
39+
}

0 commit comments

Comments
 (0)