dag: test contains

Test coverage for the `Dag::contains` method were not covered. Add tests for the
method to cover an empty and filled `Dag`.
This commit is contained in:
Fintan Halpenny 2024-11-11 13:47:59 +00:00 committed by cloudhead
parent 6c8ee4330e
commit 159d3fce93
No known key found for this signature in database
1 changed files with 20 additions and 0 deletions

View File

@ -1020,4 +1020,24 @@ mod tests {
);
assert_eq!(order, vec!["R", "A3", "A2", "B3", "A1", "B2", "B1", "C1"]);
}
#[test]
fn test_contains() {
let mut dag = Dag::<u8, ()>::new();
assert!(!dag.contains(&0));
dag.node(0, ());
dag.node(1, ());
dag.dependency(0, 1);
dag.node(2, ());
dag.dependency(2, 1);
dag.dependency(2, 0);
dag.node(3, ());
for i in 0..4 {
assert!(dag.contains(&i));
}
assert!(!dag.contains(&4));
}
}