From c8c07c462f7db57218ade26c74dbc76734072a69 Mon Sep 17 00:00:00 2001 From: Ethan Ordentlich <eordentl@caltech.edu> Date: Sat, 23 Feb 2019 15:57:26 -0800 Subject: [PATCH] Fix directionality of edge test in common --- .../caltech/cs2/project07/MarvelTests.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/edu/caltech/cs2/project07/MarvelTests.java b/tests/edu/caltech/cs2/project07/MarvelTests.java index fbfa900..2a8ceec 100644 --- a/tests/edu/caltech/cs2/project07/MarvelTests.java +++ b/tests/edu/caltech/cs2/project07/MarvelTests.java @@ -101,7 +101,12 @@ public class MarvelTests { MARVEL_GRAPH.removeEdge(c2, c1); assertEquals(null, MARVEL_GRAPH.adjacent(c2, c1), "An edge is non-null after removal"); if (edge > 80) { - common.add(c1 + " --" + edge + "-- " + c2); + if (c1.compareTo(c2) < 0) { + common.add(c1.strip() + " --" + edge + "-- " + c2.strip()); + } + else { + common.add(c2.strip() + " --" + edge + "-- " + c1.strip()); + } } } assertTrue(MARVEL_GRAPH.neighbors(c1).isEmpty(), "After removing all of a vertex's neighbors, neighbors() is non-empty"); @@ -122,7 +127,21 @@ public class MarvelTests { } while (fr.hasNextLine()) { - expected.add(fr.nextLine()); + String l = fr.nextLine(); + // is edge - sort to remove dependence on directionality for correctness + if (l.contains("--")) { + String[] spl = l.split("--"); + String v1 = spl[0].strip(); + String v2 = spl[2].strip(); + String e = spl[1]; + if (v1.compareTo(v2) < 0) { + l = v1 + " --" + e + "-- " + v2; + } + else { + l = v2 + " --" + e + "-- " + v1; + } + } + expected.add(l); } MatcherAssert.assertThat(actual, -- GitLab