Fix tests.

This commit is contained in:
Holt59 2018-03-02 23:49:14 +01:00
parent be94c670b7
commit 5b3690b982
2 changed files with 17 additions and 25 deletions

View File

@ -52,15 +52,14 @@ public class PathTest {
d2e = new Arc(nodes[3], nodes[4], 20, speed20, null);
e2d = new Arc(nodes[4], nodes[0], 10, speed10, null);
graph = new Graph("ID", "", Arrays.asList(nodes));
graph = new Graph("ID", "", Arrays.asList(nodes), null);
emptyPath = new Path(graph, new ArrayList<Arc>());
shortPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, b2c, c2d_1 }));
longPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, b2c, c2d_1, d2e }));
loopPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, b2c, c2d_1, d2a }));
longLoopPath = new Path(graph,
Arrays.asList(new Arc[]{ a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
invalidPath = new Path(graph, Arrays.asList(new Arc[]{ a2b, c2d_1, d2e }));
shortPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1 }));
longPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2e }));
loopPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a }));
longLoopPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
invalidPath = new Path(graph, Arrays.asList(new Arc[] { a2b, c2d_1, d2e }));
}
@ -125,9 +124,8 @@ public class PathTest {
Arc[] expected;
// Simple construction
path = Path.createFastestPathFromNodes(graph,
Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2] }));
expected = new Arc[]{ a2b, b2c };
path = Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[0], nodes[1], nodes[2] }));
expected = new Arc[] { a2b, b2c };
assertEquals(expected.length, path.getArcs().size());
for (int i = 0; i < expected.length; ++i) {
assertEquals(expected[i], path.getArcs().get(i));
@ -135,8 +133,8 @@ public class PathTest {
// Not so simple construction
path = Path.createFastestPathFromNodes(graph,
Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2], nodes[3] }));
expected = new Arc[]{ a2b, b2c, c2d_3 };
Arrays.asList(new Node[] { nodes[0], nodes[1], nodes[2], nodes[3] }));
expected = new Arc[] { a2b, b2c, c2d_3 };
assertEquals(expected.length, path.getArcs().size());
for (int i = 0; i < expected.length; ++i) {
assertEquals(expected[i], path.getArcs().get(i));
@ -149,9 +147,8 @@ public class PathTest {
Arc[] expected;
// Simple construction
path = Path.createShortestPathFromNodes(graph,
Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2] }));
expected = new Arc[]{ a2b, b2c };
path = Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[0], nodes[1], nodes[2] }));
expected = new Arc[] { a2b, b2c };
assertEquals(expected.length, path.getArcs().size());
for (int i = 0; i < expected.length; ++i) {
assertEquals(expected[i], path.getArcs().get(i));
@ -159,8 +156,8 @@ public class PathTest {
// Not so simple construction
path = Path.createShortestPathFromNodes(graph,
Arrays.asList(new Node[]{ nodes[0], nodes[1], nodes[2], nodes[3] }));
expected = new Arc[]{ a2b, b2c, c2d_2 };
Arrays.asList(new Node[] { nodes[0], nodes[1], nodes[2], nodes[3] }));
expected = new Arc[] { a2b, b2c, c2d_2 };
assertEquals(expected.length, path.getArcs().size());
for (int i = 0; i < expected.length; ++i) {
assertEquals(expected[i], path.getArcs().get(i));
@ -169,12 +166,12 @@ public class PathTest {
@Test(expected = IllegalArgumentException.class)
public void testCreateFastestPathFromNodesException() {
Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[]{ nodes[1], nodes[0] }));
Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1], nodes[0] }));
}
@Test(expected = IllegalArgumentException.class)
public void testCreateShortestPathFromNodesException() {
Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[]{ nodes[1], nodes[0] }));
Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1], nodes[0] }));
}
}

View File

@ -2,9 +2,6 @@ package org.insa.graph.io;
import static org.junit.Assert.assertEquals;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
@ -23,9 +20,7 @@ public class BinaryGraphReaderTest {
@BeforeClass
public static void initAll() throws IOException {
BinaryGraphReaderInsa2016 reader = new BinaryGraphReaderInsa2016(
new DataInputStream(new BufferedInputStream(new FileInputStream("Maps/midip.map"))));
midip = reader.read();
// TODO
}
public void assertPointAt(Point p1, double longitude, double latitude) {