From 815a5cc136665f79ccab88e25a12242867f1d235 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 3 Dec 2023 15:12:32 -0300 Subject: Move tests --- 2023/day-01/src/bin/part2.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/2023/day-01/src/bin/part2.rs b/2023/day-01/src/bin/part2.rs index 5185b76..99f8748 100644 --- a/2023/day-01/src/bin/part2.rs +++ b/2023/day-01/src/bin/part2.rs @@ -19,18 +19,6 @@ fn find_min<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) { (*position, word) } -#[test] -fn test_find_min_1() { - let input = vec!((1, "eight"), (2, "eight"), (3, "2")); - assert_eq!(find_min(&input), (1, "eight")); -} - -#[test] -fn test_find_min_2() { - let input = vec!((4, "eight"), (5, "eight"), (3, "2")); - assert_eq!(find_min(&input), (3, "2")); -} - fn find_max<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) { let (position, word) = matches.iter().min_by(|(x,_), (y, _)| { y.cmp(x) @@ -58,6 +46,19 @@ fn process_line(s: &str) -> i32 { (mapping[min_number] * 10) + mapping[max_number] } + +#[test] +fn test_find_min_1() { + let input = vec!((1, "eight"), (2, "eight"), (3, "2")); + assert_eq!(find_min(&input), (1, "eight")); +} + +#[test] +fn test_find_min_2() { + let input = vec!((4, "eight"), (5, "eight"), (3, "2")); + assert_eq!(find_min(&input), (3, "2")); +} + #[test] fn simple_input() { let string = "onetwo"; -- cgit v1.2.3-70-g09d2