Release 0.3.0 #8
@@ -318,10 +318,12 @@ where
|
||||
G::Vertex: Debug,
|
||||
G::Edge: Debug,
|
||||
{
|
||||
let path = path_option.expect(&format!(
|
||||
"path should exist between source vertex {:?} and connected targets {:?}",
|
||||
source, targets
|
||||
));
|
||||
let path = path_option.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"path should exist between source vertex {:?} and connected targets {:?}",
|
||||
source, targets
|
||||
)
|
||||
});
|
||||
|
||||
if targets.contains(&source) {
|
||||
assert!(
|
||||
@@ -402,9 +404,9 @@ pub fn assert_isomorphic<G: GraphTopology, H: GraphTopology>(
|
||||
.position(|x| {
|
||||
vertex_map(x.vertex) == incidence.vertex && edge_map(x.edge) == incidence.edge
|
||||
})
|
||||
.expect(&format!(
|
||||
"unexpected incidence {incidence:?} of vertex {v:?} in the other graph"
|
||||
));
|
||||
.unwrap_or_else(|| {
|
||||
panic!("unexpected incidence {incidence:?} of vertex {v:?} in the other graph")
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
|
||||
@@ -452,10 +452,12 @@ fn assert_vertex_incidences<G: GraphTopology>(
|
||||
let pos = expected
|
||||
.iter()
|
||||
.position(|x| *x == incidence)
|
||||
.expect(&format!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from iterator after delete",
|
||||
v
|
||||
));
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from iterator after delete",
|
||||
v
|
||||
)
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
@@ -479,10 +481,12 @@ fn assert_vertex_incidence_cursor<G: GraphTopology>(
|
||||
let pos = expected
|
||||
.iter()
|
||||
.position(|x| *x == incidence)
|
||||
.expect(&format!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from cursor after delete",
|
||||
v
|
||||
));
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from cursor after delete",
|
||||
v
|
||||
)
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
@@ -508,10 +512,12 @@ fn assert_incident_edges_after_delete<G: GraphTopology>(
|
||||
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
|
||||
));
|
||||
let pos = expected.iter().position(|f| *f == e).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected incident edge {e:?} of vertex {:?} after delete",
|
||||
v
|
||||
)
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
|
||||
@@ -278,10 +278,12 @@ where
|
||||
let i = expected_adjacency
|
||||
.iter()
|
||||
.position(|w| *w == v)
|
||||
.expect(&format!(
|
||||
"unexpected adjacent vertex {v:?} of {:?} from iterator",
|
||||
vertices[4]
|
||||
));
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected adjacent vertex {v:?} of {:?} from iterator",
|
||||
vertices[4]
|
||||
)
|
||||
});
|
||||
expected_adjacency.swap_remove(i);
|
||||
}
|
||||
assert_eq!(
|
||||
@@ -443,10 +445,12 @@ where
|
||||
);
|
||||
let mut expected: Vec<_> = incidences[i].iter().map(|x| x.edge).collect();
|
||||
for e in graph.incident_edges(vertices[i]) {
|
||||
let pos = expected.iter().position(|f| *f == e).expect(&format!(
|
||||
"unexpected incident edge {e:?} of vertex {:?} from iterator",
|
||||
vertices[i]
|
||||
));
|
||||
let pos = expected.iter().position(|f| *f == e).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected incident edge {e:?} of vertex {:?} from iterator",
|
||||
vertices[i]
|
||||
)
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
@@ -487,10 +491,9 @@ where
|
||||
for i in 0..2 {
|
||||
let mut expected = edges.to_vec();
|
||||
for e in graph.incident_edges(vertices[i]) {
|
||||
let pos = expected.iter().position(|f| *f == e).expect(&format!(
|
||||
"unexpected incident edge {e:?} of vertex {:?}",
|
||||
vertices[i]
|
||||
));
|
||||
let pos = expected.iter().position(|f| *f == e).unwrap_or_else(|| {
|
||||
panic!("unexpected incident edge {e:?} of vertex {:?}", vertices[i])
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
@@ -529,10 +532,12 @@ where
|
||||
let pos = expected
|
||||
.iter()
|
||||
.position(|x| *x == incidence)
|
||||
.expect(&format!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from iterator",
|
||||
vertices[i]
|
||||
));
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from iterator",
|
||||
vertices[i]
|
||||
)
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
@@ -611,10 +616,12 @@ where
|
||||
for i in 0..2 {
|
||||
let mut iter = graph.incidences(vertices[i]);
|
||||
for j in 0..K {
|
||||
let current = iter.next().expect(&format!(
|
||||
"incidence {j} missing, expected {K} incidences for vertex {:?}",
|
||||
vertices[i]
|
||||
));
|
||||
let current = iter.next().unwrap_or_else(|| {
|
||||
panic!(
|
||||
"incidence {j} missing, expected {K} incidences for vertex {:?}",
|
||||
vertices[i]
|
||||
)
|
||||
});
|
||||
assert_eq!(
|
||||
current.vertex,
|
||||
vertices[1 - i],
|
||||
@@ -665,10 +672,12 @@ where
|
||||
let pos = expected
|
||||
.iter()
|
||||
.position(|x| *x == incidence)
|
||||
.expect(&format!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from cursor",
|
||||
vertices[i]
|
||||
));
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"unexpected incidence {incidence:?} of vertex {:?} from cursor",
|
||||
vertices[i]
|
||||
)
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
@@ -710,10 +719,12 @@ where
|
||||
for i in 0..2 {
|
||||
let mut cursor = graph.incidence_cursor(vertices[i]);
|
||||
for j in 0..K {
|
||||
let current = cursor.next(&graph).expect(&format!(
|
||||
"incidence {j} missing, expected {K} incidences for vertex {:?}",
|
||||
vertices[i]
|
||||
));
|
||||
let current = cursor.next(&graph).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"incidence {j} missing, expected {K} incidences for vertex {:?}",
|
||||
vertices[i]
|
||||
)
|
||||
});
|
||||
assert_eq!(
|
||||
current.vertex,
|
||||
vertices[1 - i],
|
||||
@@ -789,9 +800,9 @@ where
|
||||
for u in graph.vertices() {
|
||||
let mut expected: Vec<_> = graph.incidences(u).map(|x| x.edge).collect();
|
||||
for e in graph.incident_edges(u) {
|
||||
let pos = expected.iter().position(|f| *f == e).expect(&format!(
|
||||
"incident edge {e:?} of vertex {u:?} missing from incidences"
|
||||
));
|
||||
let pos = expected.iter().position(|f| *f == e).unwrap_or_else(|| {
|
||||
panic!("incident edge {e:?} of vertex {u:?} missing from incidences")
|
||||
});
|
||||
expected.swap_remove(pos);
|
||||
}
|
||||
assert!(
|
||||
|
||||
Reference in New Issue
Block a user