Refactor tests: use MakeTestGraph in model-specific tests, deconstruct vertex arrays where useful, adjust local variable names
This commit is contained in:
@@ -58,7 +58,7 @@ impl<G: GraphTopologyAddition> MakeTestGraph for G {
|
||||
(vertices[7], vertices[8]),
|
||||
(vertices[7], vertices[9]),
|
||||
]
|
||||
.map(|(v1, v2)| (graph.add_edge(v1, v2), v1, v2));
|
||||
.map(|(u, v)| (graph.add_edge(u, v), u, v));
|
||||
let i = |vertex, edge| Incidence { vertex, edge };
|
||||
let incidences = [
|
||||
vec![i(vertices[1], edges[0].0), i(vertices[1], edges[1].0)],
|
||||
@@ -323,13 +323,13 @@ where
|
||||
// Walks the path: tracks current vertex, confirms each edge is incident to it.
|
||||
let mut current = source;
|
||||
for (i, &e) in path.iter().enumerate() {
|
||||
let (v1, v2) = graph.incident_vertices(e);
|
||||
assert_ne!(v1, v2, "path should not contain loop edge {e:?}");
|
||||
let (u, v) = graph.incident_vertices(e);
|
||||
assert_ne!(u, v, "path should not contain loop edge {e:?}");
|
||||
assert!(
|
||||
v1 == current || v2 == current,
|
||||
"path edge {e:?} (index {i}, vertices {v1:?} to {v2:?}) not incident to vertex {current:?}"
|
||||
u == current || v == current,
|
||||
"path edge {e:?} (index {i}, vertices {u:?} to {v:?}) not incident to vertex {current:?}"
|
||||
);
|
||||
current = if v1 == current { v2 } else { v1 };
|
||||
current = if u == current { v } else { u };
|
||||
}
|
||||
assert!(
|
||||
targets.contains(¤t),
|
||||
|
||||
Reference in New Issue
Block a user