Files
grapherity/src/testing/graph_topology_clone_testing.rs
T

37 lines
1.1 KiB
Rust

use std::fmt::Debug;
use crate::testing::fixtures;
use crate::testing::fixtures::MakeTestGraph;
#[doc(hidden)]
#[macro_export]
macro_rules! graph_topology_clone_tests {
($T:ty) => {
$crate::graph_topology_clone_tests!(@wrap $T,
clone_handles_interchangeable,
);
};
(@wrap $T:ty, $($name:ident),* $(,)?) => {
$(
#[test]
fn $name() {
$crate::testing::graph_topology_clone_testing::$name::<$T>();
}
)*
};
}
/// Queries the clone using vertex and edge handles obtained from the original graph, and asserts
/// that the results are identical to querying the original with those same handles. This is only
/// meaningful because Vertex and Edge handles are not tied to a particular graph instance.
pub fn clone_handles_interchangeable<G: Clone + MakeTestGraph>()
where
G::Vertex: Debug,
G::Edge: Debug,
{
let (graph, vertices, edges, _) = G::standard();
let clone = graph.clone();
fixtures::assert_isomorphic(&graph, &clone, &vertices, |v| v, &edges, |e| e);
}