From 38c9523d945662f08cf374461aedf0970a98ce00 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 26 Nov 2024 22:50:19 +0100 Subject: [PATCH] fix(tests): remove `test_` prefix in tests --- src/undirected/kruskal.rs | 31 ++++++++++++++++++------------- tests/cycle_detection.rs | 4 ++-- tests/gps.rs | 2 +- tests/grid.rs | 4 ++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/undirected/kruskal.rs b/src/undirected/kruskal.rs index 06868053..99e7bdbe 100644 --- a/src/undirected/kruskal.rs +++ b/src/undirected/kruskal.rs @@ -14,19 +14,24 @@ fn find(parents: &mut [usize], mut node: usize) -> usize { node } -#[test] -fn test_path_halving() { - let mut parents = vec![0, 0, 1, 2, 3, 4, 5, 6]; - assert_eq!(find(&mut parents, 7), 0); - assert_eq!(parents, vec![0, 0, 1, 1, 3, 3, 5, 5]); - assert_eq!(find(&mut parents, 7), 0); - assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 5, 3]); - assert_eq!(find(&mut parents, 7), 0); - assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 5, 0]); - assert_eq!(find(&mut parents, 6), 0); - assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 3, 0]); - assert_eq!(find(&mut parents, 6), 0); - assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 0, 0]); +#[cfg(test)] +mod tests { + use super::find; + + #[test] + fn path_halving() { + let mut parents = vec![0, 0, 1, 2, 3, 4, 5, 6]; + assert_eq!(find(&mut parents, 7), 0); + assert_eq!(parents, vec![0, 0, 1, 1, 3, 3, 5, 5]); + assert_eq!(find(&mut parents, 7), 0); + assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 5, 3]); + assert_eq!(find(&mut parents, 7), 0); + assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 5, 0]); + assert_eq!(find(&mut parents, 6), 0); + assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 3, 0]); + assert_eq!(find(&mut parents, 6), 0); + assert_eq!(parents, vec![0, 0, 1, 0, 3, 3, 0, 0]); + } } fn union(parents: &mut [usize], ranks: &mut [usize], mut a: usize, mut b: usize) { diff --git a/tests/cycle_detection.rs b/tests/cycle_detection.rs index 01573b9c..604b231a 100644 --- a/tests/cycle_detection.rs +++ b/tests/cycle_detection.rs @@ -1,11 +1,11 @@ use pathfinding::directed::cycle_detection::*; #[test] -fn test_floyd() { +fn floyd_works() { assert_eq!(floyd(-10, |x| (x + 5) % 6 + 3), (3, 6, 2)); } #[test] -fn test_brent() { +fn brent_works() { assert_eq!(brent(-10, |x| (x + 5) % 6 + 3), (3, 6, 2)); } diff --git a/tests/gps.rs b/tests/gps.rs index 4b8d2285..0e950452 100644 --- a/tests/gps.rs +++ b/tests/gps.rs @@ -68,7 +68,7 @@ fn successor_distances( } #[test] -fn test_gps() { +fn gps() { let coords = coords(); let successor_distances = successor_distances(&coords); let (start, goal) = ("Paris", "Cannes"); diff --git a/tests/grid.rs b/tests/grid.rs index e31714a1..5dbe8565 100644 --- a/tests/grid.rs +++ b/tests/grid.rs @@ -254,7 +254,7 @@ fn remove_outside_vertex() { } #[test] -fn test_outside_vertex() { +fn outside_vertex() { let mut g = Grid::new(10, 10); assert!(!g.has_vertex((10, 10))); g.fill(); @@ -585,7 +585,7 @@ fn from_matrix() { } #[test] -fn test_equality() { +fn equality() { let g = [ (0, 0), (1, 0),