use std::fmt::Debug; use crate::testing::fixtures::MakeTestGraph; use crate::traits::{GraphTopologyAddition, GraphTopologyDeletion}; #[doc(hidden)] #[macro_export] macro_rules! graph_topology_addition_deletion_tests { ($T:ty) => { $crate::graph_topology_addition_deletion_tests!(@wrap $T, delete_vertex_add_vertex, delete_edge_add_edge, ); }; (@wrap $T:ty, $($name:ident),* $(,)?) => { $( #[test] fn $name() { $crate::testing::graph_topology_addition_deletion_testing::$name::<$T>(); } )* }; } pub(crate) fn delete_vertex_add_vertex() where G::Vertex: Debug, { let (mut graph, v) = G::single_vertex(); graph.delete_vertex(v); assert_eq!( graph.vertex_count(), 0, "unexpected vertex count after delete" ); assert_ne!( graph.add_vertex(), v, "unexpected duplicate vertex after delete" ); assert_eq!( graph.vertex_count(), 1, "unexpected vertex count after re-add" ); } pub(crate) fn delete_edge_add_edge() where G::Edge: Debug, { let (mut graph, vertices, e) = G::single_edge(); graph.delete_edge(e); assert_eq!(graph.edge_count(), 0, "unexpected edge count after delete"); assert_ne!( graph.add_edge(vertices[0], vertices[1]), e, "unexpected duplicate edge after re-add" ); assert_eq!(graph.edge_count(), 1, "unexpected edge count after re-add"); }