From 873624a3f1a5fd3a0e38df867a3dc3b802cf4e94 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 27 Dec 2024 17:37:35 +0100 Subject: [PATCH] fix(clippy): put test module last in file --- src/undirected/kruskal.rs | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/undirected/kruskal.rs b/src/undirected/kruskal.rs index 99e7bdbe..deef9909 100644 --- a/src/undirected/kruskal.rs +++ b/src/undirected/kruskal.rs @@ -14,26 +14,6 @@ fn find(parents: &mut [usize], mut node: usize) -> usize { node } -#[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) { if ranks[a] < ranks[b] { mem::swap(&mut a, &mut b); @@ -98,3 +78,23 @@ where )) }) } + +#[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]); + } +}