Add new assert helper function for GraphTopologyDeletion tests

This commit is contained in:
2026-09-03 20:40:15 +02:00
parent 1209d75e15
commit 3ad448974e
2 changed files with 37 additions and 46 deletions
+31 -38
View File
@@ -354,25 +354,7 @@ where
.iter()
.filter_map(|x| (x.edge != edges[2].0).then_some(x.edge))
.collect();
assert_eq!(
graph.incident_edges(vertices[i]).count(),
expected.len(),
"unexpected incident edge count for vertex {:?} after delete",
vertices[i]
);
for e in graph.incident_edges(vertices[i]) {
let pos = expected.iter().position(|f| *f == e).expect(&format!(
"unexpected incident edge {e:?} of vertex {:?} after delete",
vertices[i]
));
expected.swap_remove(pos);
}
assert!(
expected.is_empty(),
"expected incident edges {:?} of vertex {:?} not matched after delete",
expected,
vertices[i]
);
assert_incident_edges_after_delete(&graph, vertices[i], &mut expected);
}
}
@@ -388,25 +370,7 @@ where
.iter()
.filter_map(|x| (x.vertex != vertices[2]).then_some(x.edge))
.collect();
assert_eq!(
graph.incident_edges(vertices[i]).count(),
expected.len(),
"unexpected incident edge count for vertex {:?} after delete",
vertices[i]
);
for e in graph.incident_edges(vertices[i]) {
let pos = expected.iter().position(|f| *f == e).expect(&format!(
"unexpected incident edge {e:?} of vertex {:?} after delete",
vertices[i]
));
expected.swap_remove(pos);
}
assert!(
expected.is_empty(),
"expected incident edges {:?} of vertex {:?} not matched after delete",
expected,
vertices[i]
);
assert_incident_edges_after_delete(&graph, vertices[i], &mut expected);
}
}
@@ -536,3 +500,32 @@ fn assert_vertex_incidence_cursor<G: GraphTopology>(
v
);
}
fn assert_incident_edges_after_delete<G: GraphTopology>(
graph: &G,
v: G::Vertex,
expected: &mut Vec<G::Edge>,
) where
G::Vertex: Debug,
G::Edge: Debug,
{
assert_eq!(
graph.incident_edges(v).count(),
expected.len(),
"unexpected incident edge count for vertex {:?} after delete",
v
);
for e in graph.incident_edges(v) {
let pos = expected.iter().position(|f| *f == e).expect(&format!(
"unexpected incident edge {e:?} of vertex {:?} after delete",
v
));
expected.swap_remove(pos);
}
assert!(
expected.is_empty(),
"expected incident edges {:?} of vertex {:?} not matched after delete",
expected,
v
);
}