diff --git a/exercises/practice/saddle-points/.meta/test_template.tera b/exercises/practice/saddle-points/.meta/test_template.tera index ff597d3e0..69fb2559c 100644 --- a/exercises/practice/saddle-points/.meta/test_template.tera +++ b/exercises/practice/saddle-points/.meta/test_template.tera @@ -1,9 +1,5 @@ -// We don't care about order -fn find_sorted_saddle_points(input: &[Vec]) -> Vec<(usize, usize)> { - let mut result = saddle_points::find_saddle_points(input); - result.sort_unstable(); - result -} +use saddle_points::*; + {% for test in cases %} #[test] #[ignore] @@ -11,7 +7,8 @@ fn {{ test.description | make_ident }}() { let input = &[{% for row in test.input.matrix %} vec!{{ row }}, {% endfor %}]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[ {% for p in test.expected | sort(attribute = "column") | sort(attribute = "row") %} ({{ p.row - 1 }}, {{ p.column - 1 }}), diff --git a/exercises/practice/saddle-points/tests/saddle-points.rs b/exercises/practice/saddle-points/tests/saddle-points.rs index 730772d41..351eb7b3c 100644 --- a/exercises/practice/saddle-points/tests/saddle-points.rs +++ b/exercises/practice/saddle-points/tests/saddle-points.rs @@ -1,14 +1,10 @@ -// We don't care about order -fn find_sorted_saddle_points(input: &[Vec]) -> Vec<(usize, usize)> { - let mut result = saddle_points::find_saddle_points(input); - result.sort_unstable(); - result -} +use saddle_points::*; #[test] fn can_identify_single_saddle_point() { let input = &[vec![9, 8, 7], vec![5, 3, 2], vec![6, 6, 7]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(1, 0)]; assert_eq!(output, expected); } @@ -17,7 +13,8 @@ fn can_identify_single_saddle_point() { #[ignore] fn can_identify_that_empty_matrix_has_no_saddle_points() { let input = &[vec![]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[]; assert_eq!(output, expected); } @@ -26,7 +23,8 @@ fn can_identify_that_empty_matrix_has_no_saddle_points() { #[ignore] fn can_identify_lack_of_saddle_points_when_there_are_none() { let input = &[vec![1, 2, 3], vec![3, 1, 2], vec![2, 3, 1]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[]; assert_eq!(output, expected); } @@ -35,7 +33,8 @@ fn can_identify_lack_of_saddle_points_when_there_are_none() { #[ignore] fn can_identify_multiple_saddle_points_in_a_column() { let input = &[vec![4, 5, 4], vec![3, 5, 5], vec![1, 5, 4]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(0, 1), (1, 1), (2, 1)]; assert_eq!(output, expected); } @@ -44,7 +43,8 @@ fn can_identify_multiple_saddle_points_in_a_column() { #[ignore] fn can_identify_multiple_saddle_points_in_a_row() { let input = &[vec![6, 7, 8], vec![5, 5, 5], vec![7, 5, 6]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(1, 0), (1, 1), (1, 2)]; assert_eq!(output, expected); } @@ -53,7 +53,8 @@ fn can_identify_multiple_saddle_points_in_a_row() { #[ignore] fn can_identify_saddle_point_in_bottom_right_corner() { let input = &[vec![8, 7, 9], vec![6, 7, 6], vec![3, 2, 5]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(2, 2)]; assert_eq!(output, expected); } @@ -62,7 +63,8 @@ fn can_identify_saddle_point_in_bottom_right_corner() { #[ignore] fn can_identify_saddle_points_in_a_non_square_matrix() { let input = &[vec![3, 1, 3], vec![3, 2, 4]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(0, 0), (0, 2)]; assert_eq!(output, expected); } @@ -71,7 +73,8 @@ fn can_identify_saddle_points_in_a_non_square_matrix() { #[ignore] fn can_identify_that_saddle_points_in_a_single_column_matrix_are_those_with_the_minimum_value() { let input = &[vec![2], vec![1], vec![4], vec![1]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(1, 0), (3, 0)]; assert_eq!(output, expected); } @@ -80,7 +83,8 @@ fn can_identify_that_saddle_points_in_a_single_column_matrix_are_those_with_the_ #[ignore] fn can_identify_that_saddle_points_in_a_single_row_matrix_are_those_with_the_maximum_value() { let input = &[vec![2, 5, 3, 5]]; - let output = find_sorted_saddle_points(input); + let mut output = find_saddle_points(input); + output.sort_unstable(); let expected = &[(0, 1), (0, 3)]; assert_eq!(output, expected); }