forked from woowacourse-precourse/java-calculator-7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationTest.java
More file actions
93 lines (80 loc) · 2.39 KB
/
ApplicationTest.java
File metadata and controls
93 lines (80 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package calculator;
import static camp.nextstep.edu.missionutils.test.Assertions.assertSimpleTest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import camp.nextstep.edu.missionutils.test.NsTest;
import org.junit.jupiter.api.Test;
class ApplicationTest extends NsTest {
@Test
void 커스텀_구분자_사용() {
assertSimpleTest(() -> {
run("//;\\n1");
assertThat(output()).contains("결과 : 1");
});
}
@Test
void 예외_테스트() {
assertSimpleTest(() ->
assertThatThrownBy(() -> runException("-1,2,3"))
.isInstanceOf(IllegalArgumentException.class)
);
}
@Override
public void runMain() {
Application.main(new String[]{});
}
@Test
public void 숫자_구분자_사용() {
assertSimpleTest(() -> {
run("//1\\n2:213");
assertThat(output()).contains("결과 : 7");
});
}
@Test
public void 탈출_문자_사용() {
assertSimpleTest(() -> {
assertThatThrownBy(() -> runException("1\\2:3"))
.isInstanceOf(IllegalArgumentException.class);
});
}
@Test
public void 탈출_문자_구분자_사용() {
assertSimpleTest(() -> {
run("//\\\\n1\\2:3,4");
assertThat(output()).contains("결과 : 10");
});
}
@Test
public void 마침표_구분자_사용() {
assertSimpleTest(() -> {
run("//.\\n1.2.4:3");
assertThat(output()).contains("결과 : 10");
});
}
@Test
public void 마침표_사용(){
assertThatThrownBy(() -> runException("1.2.3:4"))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void 따옴표_구분자_사용() {
assertSimpleTest(() -> {
run("//\"\\n1\"2\"4:3");
assertThat(output()).contains("결과 : 10");
});
}
@Test
public void 구분자_사이에_문자열_없음() {
assertSimpleTest(() -> {
run("1,:2");
assertThat(output()).contains("결과 : 3");
});
}
@Test
public void 문자열_없음(){
assertSimpleTest(() -> {
run("\n");
assertThat(output()).contains("결과 : 0");
});
}
}