-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrashGraphTest.java
More file actions
69 lines (56 loc) · 1.69 KB
/
CrashGraphTest.java
File metadata and controls
69 lines (56 loc) · 1.69 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
package cas2xb3.greenlightTests;
import static org.junit.Assert.*;
import edu.princeton.cs.algs4.*;
import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cas2xb3.greenlight.CrashGraph;
import cas2xb3.greenlight.Data;
public class CrashGraphTest {
private static EdgeWeightedDigraph G;
private static int numOfCrashes;
@Before
public void setUp() throws Exception {
G = CrashGraph.FinalGraph();
numOfCrashes = Data.getCollisionCount();
}
@After
public void tearDown() throws Exception {
G = null;
numOfCrashes = 0;
}
@Test
// Tests the crash point at index 0; and the adjacent north, south, west, and east crashes
public void NSWECrashesTest1() {
boolean result = false;
int[] NSWEfor0 = CrashGraph.NSWECrashes(0);
// Compares the results with the results found from the data set
if (NSWEfor0[0] == 1832 && NSWEfor0[1] == 303 && NSWEfor0[2] == 234 && NSWEfor0[3] == 3244 ){
result = true;
}
assertTrue(result);
}
@Test
// Tests point that has no eastern crash
public void NSWECrashesTest2() {
boolean result = false;
int[] NSWE = CrashGraph.NSWECrashes(1021);
// Compares the results with the results found from the data set
// 90000 is the null point
if (NSWE[0] == 2907 && NSWE[1] == 490 && NSWE[2] == 253 && NSWE[3] == 90000 ){
result = true;
}
assertTrue(result);
}
@Test
// Confirms that the graph is not empty
public void FinalGraphTest() throws IOException {
assertTrue(G != null);
}
@Test
// Confirms that the graph is the right size
public void FinalGraphTest2() throws IOException {
assertTrue(G.V() == numOfCrashes);
}
}