refactor(test): dijkstra no path assertion

This commit is contained in:
Paul Alnet 2024-05-20 22:26:13 +02:00
parent 0ad795a8c4
commit f62e312156

View file

@ -91,6 +91,19 @@ public class DijkstraAlgorithmTest {
assert(Math.abs(dijkstra.getCostPath() - dijk_path.getPath().getLength()) < 1.0);
assert(Math.abs(dijk_path.getPath().getLength() - bell_path.getPath().getLength()) < 1.0);
}
/*
* Verifies that no path is found
*/
private void assertNoPathFound(Graph graph, Node origin, Node destination, ArcInspector arcFilter) {
ShortestPathData data = new ShortestPathData(graph, origin, destination, arcFilter);
DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(data);
ShortestPathSolution dijk_path = dijkstra.doRun();
assert(!dijk_path.isFeasible());
assert(dijk_path.getPath() == null);
}
@Test
/*
@ -137,13 +150,8 @@ public class DijkstraAlgorithmTest {
Graph myGraph = graph.get(0);
Node origin = myGraph.get(3);
Node destination = myGraph.get(3);
ShortestPathData data = new ShortestPathData(myGraph, origin, destination, arcInspector);
DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(data);
ShortestPathSolution dijk_path = dijkstra.doRun();
assert(!dijk_path.isFeasible());
assert(dijk_path.getPath() == null);
assertNoPathFound(myGraph, origin, destination, arcInspector);
}
@Test
@ -159,12 +167,8 @@ public class DijkstraAlgorithmTest {
Graph myGraph = graph.get(1);
Node origin = myGraph.get(224);
Node destination = myGraph.get(814);
ShortestPathData data = new ShortestPathData(myGraph, origin, destination, arcInspector);
DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(data);
ShortestPathSolution dijk_path = dijkstra.doRun();
assert(!dijk_path.isFeasible());
assert(dijk_path.getPath() == null);
assertNoPathFound(myGraph, origin, destination, arcInspector);
}
@Test