-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunwayTests.java
111 lines (98 loc) · 3.97 KB
/
RunwayTests.java
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class RunwayTests
{
@Test
public void createRunwayBoundary()
{
try {
Runway run = new Runway(0, 0, new RunwayData(0, 0, 0, 0), new RunwayData(0, 0, 0, 0));
assertTrue(run.getName().equals("00L/18R"));
assertTrue(run.getGradedArea() == 0);
run = new Runway(0, new RunwayData(0, 0, 0, 0), new RunwayData(0, 0, 0, 0));
assertTrue(run.getName().equals("00L/18R"));
assertTrue(run.getGradedArea() == 400);
} catch (Exception e) {}
boolean bearing = false;
boolean leftNull = false;
boolean rightNull = false;
boolean graded = false;
try {
Runway run = new Runway(-1, 0, new RunwayData(0, 0, 0, 0), new RunwayData(0, 0, 0, 0));
} catch(Exception e) {
try {
Runway run = new Runway(-1, new RunwayData(0, 0, 0, 0), new RunwayData(0, 0, 0, 0));
} catch(Exception ex) {
bearing = true;
}
}
try {
Runway run = new Runway(0, 0, null, new RunwayData(0, 0, 0, 0));
} catch(Exception e) {
try {
Runway run = new Runway(0, null, new RunwayData(0, 0, 0, 0));
} catch(Exception ex) {
leftNull = true;
}
}
try {
Runway run = new Runway(0, 0, new RunwayData(0, 0, 0, 0), null);
} catch(Exception e) {
try {
Runway run = new Runway(0, new RunwayData(0, 0, 0, 0), null);
} catch(Exception ex) {
rightNull = true;
}
}
try {
Runway run = new Runway(0, -1, new RunwayData(0, 0, 0, 0), new RunwayData(0, 0, 0, 0));
} catch(Exception e) {
graded = true;
}
assertTrue(bearing);
assertTrue(leftNull);
assertTrue(rightNull);
assertTrue(graded);
}
@Test
public void testRunwayNamingConventions()
{
Runway rw = null;
Runway rw2 = null;
Runway rw3 = null;
try {
rw = new Runway(33, new RunwayData(306, 3902, 3902, 3902, 3595), new RunwayData(0, 3884, 3962, 3884, 3884));
} catch (Exception e) {}
assertTrue(rw.getRunL().getName().equals("33L"));
assertTrue(rw.getRunR().getName().equals("15R"));
assertTrue(rw.getName().equals("33L/15R"));
try {
rw2 = new Runway(1, new RunwayData(306, 3902, 3902, 3902, 3595), new RunwayData(0, 3884, 3962, 3884, 3884));
} catch (Exception e) {}
assertTrue(rw2.getRunL().getName().equals("01L"));
assertTrue(rw2.getRunR().getName().equals("19R"));
assertTrue(rw2.getName().equals("01L/19R"));
try {
rw3 = new Runway(13, new RunwayData(306, 3902, 3902, 3902, 3595), new RunwayData(0, 3884, 3962, 3884, 3884));
} catch (Exception e) {}
assertTrue(rw3.getRunL().getName().equals("13L"));
assertTrue(rw3.getRunR().getName().equals("31R"));
assertTrue(rw3.getName().equals("13L/31R"));
}
@Test
public void testAddingObstacles()
{
try {
Runway rw = null;
rw = new Runway(0, new RunwayData(306, 3902, 3902, 3902, 3595), new RunwayData(0, 3884, 3962, 3884, 3884));
ObstacleData l = new ObstacleData(new Point(406, 0), 45, 0);
ObstacleData r = new ObstacleData(new Point(286, 0), 13, 0);
rw.checkObstacle(l, new Point(0, 0));
rw.checkObstacle(r, new Point(0, 0));
assertTrue(BackendHelpers.obstacleEqual(rw.getRunL().getImpactfulObstacles().get(0), l));
assertTrue(rw.getRunL().getImpactfulObstacles().size() == 2);
assertTrue(BackendHelpers.obstacleEqual(rw.getRunR().getImpactfulObstacles().get(1), r));
assertTrue(rw.getRunR().getImpactfulObstacles().size() == 2);
} catch (Exception e) {}
}
}