File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import org .junit .jupiter .api .DisplayName ;
2+ import org .junit .jupiter .api .Test ;
3+
4+ import static org .assertj .core .api .Assertions .assertThat ;
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ @ DisplayName ("String Calculator Assert Test" )
8+ public class StringCalculatorAssertTest {
9+
10+ private StringCalculator calculator = new StringCalculator ();
11+
12+ @ Test
13+ @ DisplayName ("빈 문자열을 입력하면 0을 반환한다." )
14+ void input_empty_string () {
15+ String input = "" ;
16+
17+ // 인자를 비교하는 다양한 방법
18+ assertEquals (calculator .calculate (input ), 0 );
19+ assertThat (calculator .calculate (input )).isZero ();
20+ assertThat (calculator .calculate (input )).isEqualTo (0 );
21+ }
22+
23+ @ Test
24+ @ DisplayName ("숫자만 입력하면 숫자를 그대로 리턴한다." )
25+ void input_only_numbers () {
26+ String input = "123" ;
27+
28+ assertThat (calculator .calculate (input )).isEqualTo (123 );
29+ }
30+
31+ @ Test
32+ @ DisplayName ("기본 구분자가 포함된 문자열을 입력하면 숫자만 분리해 합한다." )
33+ void input_numbers_with_basic_separator () {
34+ String input = "1;2,3" ;
35+
36+ assertThat (calculator .calculate (input )).isEqualTo (6 );
37+ }
38+
39+ @ Test
40+ @ DisplayName ("커스텀 구분자가 포함된 문자열을 입력하면 숫자만 분리해 합한다." )
41+ void input_numbers_with_custom_separator () {
42+ String input = "//*\n 1;2,3" ;
43+
44+ assertThat (calculator .calculate (input )).isEqualTo (6 );
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments