Remove function calls inside of 'expect'
This commit is contained in:
@@ -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