From 5825ef3b47f5fecab8ccc385da84cc0c0927de73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Wed, 2 Sep 2026 09:30:37 +0200 Subject: [PATCH] Change all graph tests to pub to avoid unused-warnings --- src/testing.rs | 8 +- ...raph_topology_addition_deletion_testing.rs | 5 +- .../graph_topology_addition_testing.rs | 21 ++--- .../graph_topology_deletion_testing.rs | 35 ++++---- src/testing/graph_topology_testing.rs | 83 ++++++++++--------- 5 files changed, 78 insertions(+), 74 deletions(-) diff --git a/src/testing.rs b/src/testing.rs index d730642..7b6b7d6 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -1,7 +1,7 @@ //! Test fixture and test macros for graph topology and algorithm implementations. pub mod fixtures; -pub(crate) mod graph_topology_addition_deletion_testing; -pub(crate) mod graph_topology_addition_testing; -pub(crate) mod graph_topology_deletion_testing; -pub(crate) mod graph_topology_testing; +pub mod graph_topology_addition_deletion_testing; +pub mod graph_topology_addition_testing; +pub mod graph_topology_deletion_testing; +pub mod graph_topology_testing; diff --git a/src/testing/graph_topology_addition_deletion_testing.rs b/src/testing/graph_topology_addition_deletion_testing.rs index 14fb7be..ce01b82 100644 --- a/src/testing/graph_topology_addition_deletion_testing.rs +++ b/src/testing/graph_topology_addition_deletion_testing.rs @@ -23,7 +23,7 @@ macro_rules! graph_topology_addition_deletion_tests { }; } -pub(crate) fn delete_vertex_add_vertex() +pub fn delete_vertex_add_vertex() where G::Vertex: Debug, { @@ -46,7 +46,7 @@ where ); } -pub(crate) fn delete_edge_add_edge() +pub fn delete_edge_add_edge() where G::Edge: Debug, { @@ -60,3 +60,4 @@ where ); assert_eq!(graph.edge_count(), 1, "unexpected edge count after re-add"); } + diff --git a/src/testing/graph_topology_addition_testing.rs b/src/testing/graph_topology_addition_testing.rs index 386fa8d..7123300 100644 --- a/src/testing/graph_topology_addition_testing.rs +++ b/src/testing/graph_topology_addition_testing.rs @@ -30,7 +30,7 @@ macro_rules! graph_topology_addition_tests { }; } -pub(crate) fn reserve_vertices_increases_capacity() { +pub fn reserve_vertices_increases_capacity() { let mut graph = G::default(); let capacity_before = graph.vertex_capacity(); graph.reserve_vertices(capacity_before + 10); @@ -40,7 +40,7 @@ pub(crate) fn reserve_vertices_increases_capacity() { ); } -pub(crate) fn reserve_vertices_prevents_reallocation_on_add() { +pub fn reserve_vertices_prevents_reallocation_on_add() { let mut graph = G::default(); graph.reserve_vertices(10); let capacity_before = graph.vertex_capacity(); @@ -54,7 +54,7 @@ pub(crate) fn reserve_vertices_prevents_reallocation_on_add() { +pub fn reserve_vertices_does_not_affect_edge_capacity() { let mut graph = G::default(); let capacity_before = graph.edge_capacity(); graph.reserve_vertices(10); @@ -65,7 +65,7 @@ pub(crate) fn reserve_vertices_does_not_affect_edge_capacity() { +pub fn reserve_edges_increases_capacity() { let mut graph = G::default(); let capacity_before = graph.edge_capacity(); graph.reserve_edges(capacity_before + 10); @@ -75,7 +75,7 @@ pub(crate) fn reserve_edges_increases_capacity() { ); } -pub(crate) fn reserve_edges_prevents_reallocation_on_add() { +pub fn reserve_edges_prevents_reallocation_on_add() { let mut graph = G::default(); let v1 = graph.add_vertex(); let v2 = graph.add_vertex(); @@ -91,7 +91,7 @@ pub(crate) fn reserve_edges_prevents_reallocation_on_add() { +pub fn reserve_edges_does_not_affect_vertex_capacity() { let mut graph = G::default(); let capacity_before = graph.vertex_capacity(); graph.reserve_edges(10); @@ -102,7 +102,7 @@ pub(crate) fn reserve_edges_does_not_affect_vertex_capacity() +pub fn add_vertex() where G::Vertex: Debug, { @@ -111,7 +111,7 @@ where assert_ne!(graph.add_vertex(), v, "unexpected duplicate vertex"); } -pub(crate) fn add_edge() +pub fn add_edge() where G::Edge: Debug, { @@ -122,7 +122,7 @@ where assert_ne!(graph.add_edge(v1, v2), e, "unexpected duplicate edge"); } -pub(crate) fn vertex_map_new_vertex() { +pub fn vertex_map_new_vertex() { let mut graph = G::default(); let mut map = graph.vertex_map(27); let v = graph.add_vertex(); @@ -137,7 +137,7 @@ pub(crate) fn vertex_map_new_vertex() { ); } -pub(crate) fn edge_map_new_edge() { +pub fn edge_map_new_edge() { let mut graph = G::default(); let v1 = graph.add_vertex(); let v2 = graph.add_vertex(); @@ -150,3 +150,4 @@ pub(crate) fn edge_map_new_edge() { "unexpected value from map read after write for new edge" ); } + diff --git a/src/testing/graph_topology_deletion_testing.rs b/src/testing/graph_topology_deletion_testing.rs index d530df7..1f1f684 100644 --- a/src/testing/graph_topology_deletion_testing.rs +++ b/src/testing/graph_topology_deletion_testing.rs @@ -40,7 +40,7 @@ macro_rules! graph_topology_deletion_tests { }; } -pub(crate) fn delete_vertex() { +pub fn delete_vertex() { let (mut graph, v) = G::single_vertex(); assert_eq!( graph.vertex_count(), @@ -55,7 +55,7 @@ pub(crate) fn delete_vertex() ); } -pub(crate) fn delete_vertex_loop() { +pub fn delete_vertex_loop() { let (mut graph, v, _) = G::loop_edge(); assert_eq!( graph.vertex_count(), @@ -77,7 +77,7 @@ pub(crate) fn delete_vertex_loop() { +pub fn delete_vertex_invalid_index() { let (mut graph, v) = G::single_vertex(); graph.delete_vertex(v); let result = @@ -85,7 +85,7 @@ pub(crate) fn delete_vertex_invalid_index() +pub fn delete_vertex_connected() where G::Vertex: Debug, { @@ -135,7 +135,7 @@ where } } -pub(crate) fn delete_edge() { +pub fn delete_edge() { let (mut graph, vertices, e) = G::single_edge(); assert_eq!( graph.vertex_count(), @@ -180,7 +180,7 @@ pub(crate) fn delete_edge() { ); } -pub(crate) fn delete_edge_loop() { +pub fn delete_edge_loop() { let (mut graph, v, e) = G::loop_edge(); assert_eq!( graph.vertex_count(), @@ -207,7 +207,7 @@ pub(crate) fn delete_edge_loop assert_eq!(graph.degree(v), 0, "unexpected vertex degree after delete"); } -pub(crate) fn delete_edge_multiple() { +pub fn delete_edge_multiple() { const K: usize = 2; let (mut graph, vertices, edges) = G::multiple_edges::(); assert_eq!( @@ -257,7 +257,7 @@ pub(crate) fn delete_edge_multiple() { +pub fn delete_edge_invalid_index() { let (mut graph, _, e) = G::single_edge(); graph.delete_edge(e); let result = @@ -265,7 +265,7 @@ pub(crate) fn delete_edge_invalid_index() +pub fn vertices_after_delete() where G::Vertex: Debug, { @@ -297,7 +297,7 @@ where } } -pub(crate) fn incident_vertices_after_delete_edge< +pub fn incident_vertices_after_delete_edge< G: GraphTopologyDeletion + GraphTopologyAddition, >() where @@ -316,7 +316,7 @@ where } } -pub(crate) fn edges_after_delete() +pub fn edges_after_delete() where G::Edge: Debug, { @@ -344,7 +344,7 @@ where } } -pub(crate) fn incident_edges_after_delete_edge() +pub fn incident_edges_after_delete_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -378,7 +378,7 @@ where } } -pub(crate) fn incident_edges_after_delete_vertex() +pub fn incident_edges_after_delete_vertex() where G::Vertex: Debug, G::Edge: Debug, @@ -412,7 +412,7 @@ where } } -pub(crate) fn incidences_after_delete_vertex() +pub fn incidences_after_delete_vertex() where G::Vertex: Debug, G::Edge: Debug, @@ -429,7 +429,7 @@ where } } -pub(crate) fn incidences_after_delete_edge() +pub fn incidences_after_delete_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -446,7 +446,7 @@ where } } -pub(crate) fn incidence_cursor_after_delete_vertex< +pub fn incidence_cursor_after_delete_vertex< G: GraphTopologyDeletion + GraphTopologyAddition, >() where @@ -465,7 +465,7 @@ where } } -pub(crate) fn incidence_cursor_after_delete_edge() +pub fn incidence_cursor_after_delete_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -540,3 +540,4 @@ fn assert_vertex_incidence_cursor( v ); } + diff --git a/src/testing/graph_topology_testing.rs b/src/testing/graph_topology_testing.rs index 1d45f83..cdb5dc8 100644 --- a/src/testing/graph_topology_testing.rs +++ b/src/testing/graph_topology_testing.rs @@ -62,17 +62,17 @@ macro_rules! graph_topology_tests { }; } -pub(crate) fn vertex_count_empty() { +pub fn vertex_count_empty() { let graph = G::empty(); assert_eq!(graph.vertex_count(), 0, "unexpected vertex count"); } -pub(crate) fn vertex_count() { +pub fn vertex_count() { let (graph, _, _, _) = G::standard(); assert_eq!(graph.vertex_count(), 10, "unexpected vertex count"); } -pub(crate) fn vertex_map() { +pub fn vertex_map() { let (graph, v) = G::single_vertex(); let mut map = graph.vertex_map(27); assert_eq!(map[v], 27, "unexpected value from default map read"); @@ -80,17 +80,17 @@ pub(crate) fn vertex_map() { assert_eq!(map[v], 9, "unexpected value from map after write"); } -pub(crate) fn edge_count_empty() { +pub fn edge_count_empty() { let graph = G::empty(); assert_eq!(graph.edge_count(), 0, "unexpected edge count"); } -pub(crate) fn edge_count() { +pub fn edge_count() { let (graph, _, _, _) = G::standard(); assert_eq!(graph.edge_count(), 18, "unexpected edge count"); } -pub(crate) fn edge_map() { +pub fn edge_map() { let (graph, _, e) = G::single_edge(); let mut map = graph.edge_map(28); assert_eq!(map[e], 28, "unexpected value from default map read"); @@ -98,12 +98,12 @@ pub(crate) fn edge_map() { assert_eq!(map[e], 8, "unexpected value from map after write"); } -pub(crate) fn degree_zero() { +pub fn degree_zero() { let (graph, v) = G::single_vertex(); assert_eq!(graph.degree(v), 0, "unexpected non-zero degree"); } -pub(crate) fn degree() +pub fn degree() where G::Vertex: Debug, { @@ -119,7 +119,7 @@ where } } -pub(crate) fn loop_edge() { +pub fn loop_edge() { let (graph, v, _) = G::loop_edge(); assert_eq!(graph.vertex_count(), 1, "unexpected vertex count"); assert_eq!(graph.edge_count(), 1, "unexpected edge count"); @@ -130,7 +130,7 @@ pub(crate) fn loop_edge() { ); } -pub(crate) fn multiple_edges() +pub fn multiple_edges() where G::Vertex: Debug, { @@ -156,7 +156,7 @@ where ); } -pub(crate) fn are_adjacent_vertex_self() { +pub fn are_adjacent_vertex_self() { let (graph, v) = G::single_vertex(); assert!( !graph.are_adjacent(v, v), @@ -164,7 +164,7 @@ pub(crate) fn are_adjacent_vertex_self() { ); } -pub(crate) fn are_adjacent_single_edge() { +pub fn are_adjacent_single_edge() { let (graph, vertices, _) = G::single_edge(); assert!( graph.are_adjacent(vertices[0], vertices[1]), @@ -176,7 +176,7 @@ pub(crate) fn are_adjacent_single_edge() { ); } -pub(crate) fn are_adjacent() +pub fn are_adjacent() where G::Vertex: Debug, { @@ -221,7 +221,7 @@ where } } -pub(crate) fn vertices_empty() { +pub fn vertices_empty() { let graph = G::empty(); assert_eq!( graph.vertices().count(), @@ -230,7 +230,7 @@ pub(crate) fn vertices_empty() { ); } -pub(crate) fn vertices() +pub fn vertices() where G::Vertex: Debug, { @@ -245,7 +245,7 @@ where } } -pub(crate) fn adjacent_vertices_empty() { +pub fn adjacent_vertices_empty() { let (graph, v) = G::single_vertex(); assert_eq!( graph.adjacent_vertices(v).count(), @@ -254,7 +254,7 @@ pub(crate) fn adjacent_vertices_empty() { ); } -pub(crate) fn adjacent_vertices() +pub fn adjacent_vertices() where G::Vertex: Debug, { @@ -292,7 +292,7 @@ where ); } -pub(crate) fn adjacent_vertices_loop_edge() +pub fn adjacent_vertices_loop_edge() where G::Vertex: Debug, { @@ -311,7 +311,7 @@ where ); } -pub(crate) fn adjacent_vertices_multiple_edges() +pub fn adjacent_vertices_multiple_edges() where G::Vertex: Debug, { @@ -336,7 +336,7 @@ where } } -pub(crate) fn incident_vertices_single_edge() +pub fn incident_vertices_single_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -349,7 +349,7 @@ where ); } -pub(crate) fn incident_vertices_loop_edge() +pub fn incident_vertices_loop_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -362,7 +362,7 @@ where ); } -pub(crate) fn incident_vertices_multiple_edges() +pub fn incident_vertices_multiple_edges() where G::Vertex: Debug, G::Edge: Debug, @@ -383,7 +383,7 @@ where ); } -pub(crate) fn incident_vertices() +pub fn incident_vertices() where G::Vertex: Debug, G::Edge: Debug, @@ -398,7 +398,7 @@ where } } -pub(crate) fn edges_empty() { +pub fn edges_empty() { let graph = G::empty(); assert_eq!( graph.edges().count(), @@ -407,7 +407,7 @@ pub(crate) fn edges_empty() { ); } -pub(crate) fn edges() +pub fn edges() where G::Edge: Debug, { @@ -422,7 +422,7 @@ where } } -pub(crate) fn incident_edges_empty() { +pub fn incident_edges_empty() { let (graph, v) = G::single_vertex(); assert_eq!( graph.incident_edges(v).count(), @@ -431,7 +431,7 @@ pub(crate) fn incident_edges_empty() { ); } -pub(crate) fn incident_edges() +pub fn incident_edges() where G::Vertex: Debug, G::Edge: Debug, @@ -461,7 +461,7 @@ where } } -pub(crate) fn incident_edges_loop_edge() +pub fn incident_edges_loop_edge() where G::Edge: Debug, { @@ -480,7 +480,7 @@ where assert_eq!(iter.next(), None, "too many incident edges from iterator"); } -pub(crate) fn incident_edges_multiple_edges() +pub fn incident_edges_multiple_edges() where G::Vertex: Debug, G::Edge: Debug, @@ -505,7 +505,7 @@ where } } -pub(crate) fn incidences_empty() { +pub fn incidences_empty() { let (graph, v) = G::single_vertex(); assert_eq!( graph.incidences(v).count(), @@ -514,7 +514,7 @@ pub(crate) fn incidences_empty() { ); } -pub(crate) fn incidences() +pub fn incidences() where G::Vertex: Debug, G::Edge: Debug, @@ -547,7 +547,7 @@ where } } -pub(crate) fn incidences_edge_consistency() +pub fn incidences_edge_consistency() where G::Vertex: Debug, G::Edge: Debug, @@ -580,7 +580,7 @@ where } } -pub(crate) fn incidences_loop_edge() +pub fn incidences_loop_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -604,7 +604,7 @@ where ); } -pub(crate) fn incidences_multiple_edges() +pub fn incidences_multiple_edges() where G::Vertex: Debug, G::Edge: Debug, @@ -641,7 +641,7 @@ where } } -pub(crate) fn incidence_cursor_empty() +pub fn incidence_cursor_empty() where G::Vertex: Debug, G::Edge: Debug, @@ -655,7 +655,7 @@ where ); } -pub(crate) fn incidence_cursor() +pub fn incidence_cursor() where G::Vertex: Debug, G::Edge: Debug, @@ -683,7 +683,7 @@ where } } -pub(crate) fn incidence_cursor_loop_edge() +pub fn incidence_cursor_loop_edge() where G::Vertex: Debug, G::Edge: Debug, @@ -703,7 +703,7 @@ where assert_eq!(cursor.next(&graph), None, "too many incidences from cursor"); } -pub(crate) fn incidence_cursor_multiple_edges() +pub fn incidence_cursor_multiple_edges() where G::Vertex: Debug, G::Edge: Debug, @@ -740,7 +740,7 @@ where } } -pub(crate) fn incidence_cursor_copy() { +pub fn incidence_cursor_copy() { let (graph, vertices, _) = G::two_edge_path(); let mut c1 = graph.incidence_cursor(vertices[1]); assert!(c1.next(&graph).is_some(), "expected first incidence"); @@ -763,7 +763,7 @@ pub(crate) fn incidence_cursor_copy() { ); } -pub(crate) fn incident_vertices_incidences_consistency() +pub fn incident_vertices_incidences_consistency() where G::Vertex: Debug, G::Edge: Debug, @@ -783,7 +783,7 @@ where } } -pub(crate) fn incident_edges_incidences_consistency() +pub fn incident_edges_incidences_consistency() where G::Vertex: Debug, G::Edge: Debug, @@ -804,3 +804,4 @@ where ); } } +