Add test for add_edge() return value

This commit is contained in:
2026-04-22 14:36:41 +02:00
parent ab830ed221
commit 41f2332735
+10 -1
View File
@@ -9,7 +9,7 @@ impl From<Vertex> for usize {
}
}
#[derive(Copy, Clone, PartialEq, Eq)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct Incidence(usize);
struct VertexIncidenceHeader {
@@ -136,6 +136,15 @@ mod tests {
assert_eq!(graph.vertex_count(), 10, "unexpected vertex count");
}
#[test]
fn add_edge() {
let mut graph = AppendGraph::new();
let v1 = graph.add_vertex();
let v2 = graph.add_vertex();
let e = graph.add_edge(v1, v2);
assert_ne!(graph.add_edge(v1, v2), e, "unexpected duplicate edge");
}
#[test]
fn edge_count_empty() {
let graph = AppendGraph::new();