From 5b3690b982a6dee933ed3994255f7436d06fa55a Mon Sep 17 00:00:00 2001 From: Holt59 Date: Fri, 2 Mar 2018 23:49:14 +0100 Subject: [PATCH] Fix tests. --- src/test/org/insa/graph/PathTest.java | 35 +++++++++---------- .../insa/graph/io/BinaryGraphReaderTest.java | 7 +--- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/test/org/insa/graph/PathTest.java b/src/test/org/insa/graph/PathTest.java index d8c3b60..b1b8025 100644 --- a/src/test/org/insa/graph/PathTest.java +++ b/src/test/org/insa/graph/PathTest.java @@ -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()); - 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] })); } } diff --git a/src/test/org/insa/graph/io/BinaryGraphReaderTest.java b/src/test/org/insa/graph/io/BinaryGraphReaderTest.java index e7cb9a0..532003c 100644 --- a/src/test/org/insa/graph/io/BinaryGraphReaderTest.java +++ b/src/test/org/insa/graph/io/BinaryGraphReaderTest.java @@ -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) {