File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
app/src/test/java/calculator Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ package calculator ;
2+
3+ import function .Calculation ;
4+ import function .Storage ;
5+ import org .junit .jupiter .api .DisplayName ;
6+ import org .junit .jupiter .api .Test ;
7+
8+ import static org .assertj .core .api .Assertions .assertThat ;
9+
10+ public class CalculatorTest {
11+ @ DisplayName ("중위표현식을 후위표현식으로 변환한다." )
12+ @ Test
13+ void checkPostfixExpression () {
14+ final String infixExp = "3 + 5 * 2 / ( 7 - 2 )" ;
15+ final String postfixExp = "3 5 2 * 7 2 - / + " ;
16+
17+ final Calculation calculation = new Calculation ();
18+ assertThat (calculation .convertPostfix (infixExp )).isEqualTo (postfixExp );
19+ }
20+
21+ @ DisplayName ("후위표현식을 계산한 결과를 출력한다." )
22+ @ Test
23+ void checkResult () {
24+ final String postfixExp = "3 5 2 * 7 2 - / +" ;
25+ final double result = 5 ;
26+
27+ final Calculation calculation = new Calculation ();
28+ assertThat (calculation .calculatePostfix (postfixExp )).isEqualTo (result );
29+ }
30+
31+ @ DisplayName ("계산한 결과가 저장된다." )
32+ @ Test
33+ void checkStore () {
34+ final String exp1 = "2 + 3 = 5" ;
35+
36+ final Storage storage = new Storage ();
37+ storage .store (exp1 );
38+
39+ assertThat (storage .print ().replace ("\n " , "" )).isEqualTo (exp1 );
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments