Skip to content

Commit

Permalink
fix(tests): remove test_ prefix in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Nov 26, 2024
1 parent 1628bd2 commit 045eaf3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
31 changes: 18 additions & 13 deletions src/undirected/kruskal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/cycle_detection.rs
Original file line number Diff line number Diff line change
@@ -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));
}
2 changes: 1 addition & 1 deletion tests/gps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions tests/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -585,7 +585,7 @@ fn from_matrix() {
}

#[test]
fn test_equality() {
fn equality() {
let g = [
(0, 0),
(1, 0),
Expand Down

0 comments on commit 045eaf3

Please sign in to comment.