Repository navigation
Expand file tree
/
Copy pathInputTest.java
More file actions
94 lines (72 loc) · 2.25 KB
/
Copy pathInputTest.java
File metadata and controls
94 lines (72 loc) · 2.25 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
94
package saru;
import saru.domain.*;
import saru.view.*;
import java.util.*;
import static org.junit.Assert.assertEquals;
import org.junit.*;
public class InputTest {
private Set<Point> points;
@Before
public void init() {
points = new HashSet<>();
}
@Test
public void checkUserInputSuccess() {
String userInputString = "(0,0)-(4,5)";
Input.getSplitedUserInputString(userInputString);
}
@Test(expected = IllegalArgumentException.class)
public void checkUserInputFail() {
String userInputString = "(200,10)-(114,15)";
Input.getSplitedUserInputString(userInputString);
}
@Test
public void checkPointsNum() {
// 해쉬셋에 저장한다. 중복과 관련.
addSetNormalValues();
// 갯수를 확인한다
assertEquals(2, points.size());
}
@Test(expected = IllegalArgumentException.class)
public void checkPointsNumFail() {
addSetTooManyValues();
new CoordinateCalc(points).calcProc();
}
@Test(expected = IllegalArgumentException.class)
public void checkPointsNumFailSame() {
addSetSameValues();
new CoordinateCalc(points).calcProc();
}
@Test(expected = IllegalArgumentException.class)
public void checkPointsAreaFailSame() {
addSetInvalidlValues();
new CoordinateCalc(points).calcProc();
}
private void addSetNormalValues() {
Point point1 = new Point(3, 3, true);
Point point2 = new Point(4, 4, true);
points.add(point1);
points.add(point2);
}
private void addSetInvalidlValues() {
Point point1 = new Point(3, 30, true);
Point point2 = new Point(4, 4, true);
points.add(point1);
points.add(point2);
}
private void addSetSameValues() {
Point point1 = new Point(3, 3, true);
Point point2 = new Point(3, 3, true);
points.add(point1);
points.add(point2);
}
private void addSetTooManyValues() {
addSetNormalValues();
Point point3 = new Point(6, 7, true);
Point point4 = new Point(8, 9, true);
Point point5 = new Point(10, 11, true);
points.add(point3);
points.add(point4);
points.add(point5);
}
}