Initial release #1

Merged
warrence merged 102 commits from dev into main 2026-06-30 10:26:52 +02:00
Showing only changes of commit 74ca390ac2 - Show all commits
+26
View File
@@ -188,6 +188,32 @@ mod tests {
}
}
#[test]
fn vertices_empty() {
let graph = Graph::new();
assert_eq!(
graph.vertices().count(),
0,
"vertex iterator of empty graph should have no elements"
);
}
#[test]
fn vertices() {
let (graph, vertices) = make_test_graph();
assert_eq!(graph.vertices().count(), 10, "unexpected vertex count");
let mut vertices: Vec<Vertex> = vertices.into_iter().collect();
for v in graph.vertices() {
if let Some(index) = vertices.iter().position(|&x| x == v) {
vertices.swap_remove(index);
} else {
panic!("unexpected vertex of {v:?} from iterator");
}
}
println!("vertices: {:?}", vertices);
}
fn make_test_graph() -> (Graph, [Vertex; 10]) {
let mut graph = Graph::new();
let vertices: [Vertex; 10] = core::array::from_fn(|_| graph.add_vertex());