diff --git a/tests/edu/caltech/cs2/project08/BeavermapTests.java b/tests/edu/caltech/cs2/project08/BeavermapTests.java index 50c73274a7d8eda85df59d0c5db9d2e080e9732a..b4ef8bea5919ad7cf27b4e77492032bc9c83fbdd 100644 --- a/tests/edu/caltech/cs2/project08/BeavermapTests.java +++ b/tests/edu/caltech/cs2/project08/BeavermapTests.java @@ -290,7 +290,12 @@ public class BeavermapTests { IDeque<Location> actualPath = bmg.dijkstra(start, target); List<Long> actualPathIDs = new ArrayList<>(); - if (actualPath != null) { + + if (expectedPathIDs.size() == 0) { + assertNull(actualPath, "Path does not exist from " + start.id + " to " + target.id + " but was found"); + } + else { + assertNotNull(actualPath, "Path exists from " + start.id + " to " + target.id + " but was not found"); for (Location l : actualPath) { actualPathIDs.add(l.id); } @@ -298,9 +303,6 @@ public class BeavermapTests { MatcherAssert.assertThat(actualPathIDs, IsIterableContainingInOrder.contains(expectedPathIDs.toArray())); } - else if (expectedPathIDs.size() != 0) { - fail("Found path from " + start.id + " to " + target.id + " where there is none."); - } } } diff --git a/tests/edu/caltech/cs2/project08/DijkstraTest.java b/tests/edu/caltech/cs2/project08/DijkstraTest.java index e8ad31e80ff3e653fd61695851a696d0c6caf7e6..533f4ddf3eb239a09a55b99c507fa4a889c3d905 100644 --- a/tests/edu/caltech/cs2/project08/DijkstraTest.java +++ b/tests/edu/caltech/cs2/project08/DijkstraTest.java @@ -79,10 +79,10 @@ public class DijkstraTest { String line = s.nextLine(); if (line.equals("null")) { - assertNull(res, "Path does not exist but was found"); + assertNull(res, "Path does not exist from " + start + " to " + end + " but was found"); } else { - assertNotNull(res, "Path exists but was not found"); + assertNotNull(res, "Path exists from " + start + " to " + end + " but was not found"); for (Location l : res) { if (prev != null) { pathLen += bmg.adjacent(prev.id, l.id); @@ -135,10 +135,10 @@ public class DijkstraTest { String line = s.nextLine(); if (line.equals("null")) { - assertNull(res, "Path does not exist but was found"); + assertNull(res, "Path does not exist from " + startvertex + " to " + endvertex + " but was found"); } else { - assertNotNull(res, "Path exists but was not found"); + assertNotNull(res, "Path exists from " + startvertex + " to " + endvertex + " but was not found"); double pathLen = 0; Location prev = null; for (Location l : res) {