Move related tests into new testing macro for GraphTopologyAddition
This commit is contained in:
@@ -241,6 +241,7 @@ mod tests {
|
|||||||
|
|
||||||
crate::graph_topology_test_fixtures!(AppendGraph);
|
crate::graph_topology_test_fixtures!(AppendGraph);
|
||||||
crate::graph_topology_tests!(AppendGraph);
|
crate::graph_topology_tests!(AppendGraph);
|
||||||
|
crate::graph_topology_addition_tests!(AppendGraph);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn incident_vertices_paired_index() {
|
fn incident_vertices_paired_index() {
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ mod tests {
|
|||||||
|
|
||||||
crate::graph_topology_test_fixtures!(Graph);
|
crate::graph_topology_test_fixtures!(Graph);
|
||||||
crate::graph_topology_tests!(Graph);
|
crate::graph_topology_tests!(Graph);
|
||||||
|
crate::graph_topology_addition_tests!(Graph);
|
||||||
crate::graph_topology_deletion_tests!(Graph);
|
crate::graph_topology_deletion_tests!(Graph);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -110,14 +110,6 @@ macro_rules! graph_topology_test_fixtures {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! graph_topology_tests {
|
macro_rules! graph_topology_tests {
|
||||||
($T:ty) => {
|
($T:ty) => {
|
||||||
#[test]
|
|
||||||
fn add_vertex() {
|
|
||||||
use $crate::traits::GraphTopologyAddition;
|
|
||||||
let mut graph = <$T>::new();
|
|
||||||
let v = graph.add_vertex();
|
|
||||||
assert_ne!(graph.add_vertex(), v, "unexpected duplicate vertex");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn vertex_count_empty() {
|
fn vertex_count_empty() {
|
||||||
use $crate::traits::GraphTopology;
|
use $crate::traits::GraphTopology;
|
||||||
@@ -145,16 +137,6 @@ macro_rules! graph_topology_tests {
|
|||||||
assert_eq!(map[v2], 27, "unexpected value from default map read for new vertex");
|
assert_eq!(map[v2], 27, "unexpected value from default map read for new vertex");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn add_edge() {
|
|
||||||
use $crate::traits::GraphTopologyAddition;
|
|
||||||
let mut graph = <$T>::new();
|
|
||||||
let v1 = graph.add_vertex();
|
|
||||||
let v2 = graph.add_vertex();
|
|
||||||
let e = graph.add_edge(v1, v2);
|
|
||||||
assert_ne!(graph.add_edge(v1, v2), e, "unexpected duplicate edge");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn edge_count_empty() {
|
fn edge_count_empty() {
|
||||||
use $crate::traits::GraphTopology;
|
use $crate::traits::GraphTopology;
|
||||||
@@ -908,7 +890,13 @@ macro_rules! graph_topology_tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! graph_topology_addition_tests {
|
||||||
|
($T:ty) => {
|
||||||
#[test]
|
#[test]
|
||||||
fn reserve_vertices_increases_capacity() {
|
fn reserve_vertices_increases_capacity() {
|
||||||
use $crate::traits::GraphTopologyAddition;
|
use $crate::traits::GraphTopologyAddition;
|
||||||
@@ -992,6 +980,24 @@ macro_rules! graph_topology_tests {
|
|||||||
"reserve_edges must not change vertex capacity"
|
"reserve_edges must not change vertex capacity"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn add_vertex() {
|
||||||
|
use $crate::traits::GraphTopologyAddition;
|
||||||
|
let mut graph = <$T>::new();
|
||||||
|
let v = graph.add_vertex();
|
||||||
|
assert_ne!(graph.add_vertex(), v, "unexpected duplicate vertex");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn add_edge() {
|
||||||
|
use $crate::traits::GraphTopologyAddition;
|
||||||
|
let mut graph = <$T>::new();
|
||||||
|
let v1 = graph.add_vertex();
|
||||||
|
let v2 = graph.add_vertex();
|
||||||
|
let e = graph.add_edge(v1, v2);
|
||||||
|
assert_ne!(graph.add_edge(v1, v2), e, "unexpected duplicate edge");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user