refactor(test): dijkstra no path assertion
This commit is contained in:
parent
0ad795a8c4
commit
f62e312156
1 changed files with 16 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue