From 4267b682538d2798d17b1fc05d4651de8a16f0f7 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 1 Dec 2023 16:33:40 +0000 Subject: [PATCH] Created a set of unit tests each day --- src/solutions/day01.rs | 31 +++++++++++++++++++++++++++++++ src/solutions/day02.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/solutions/day01.rs b/src/solutions/day01.rs index 1de95e1..505f128 100644 --- a/src/solutions/day01.rs +++ b/src/solutions/day01.rs @@ -94,3 +94,34 @@ impl Day01 { } } } + +/// Test from puzzle input +#[cfg(test)] +mod test { + use crate::*; + use super::*; + + #[test] + fn part1() { + let challenge = day01::Day01{}; + + //Complete the Challenge + let answer = challenge.part1( + get_input(challenge.get_day(), utils::InputType::Test1).unwrap().as_mut() + ).unwrap().to_string(); + + assert_eq!(answer, "142"); + } + + #[test] + fn part2() { + let challenge = day01::Day01{}; + + //Complete the Challenge + let answer = challenge.part2( + get_input(challenge.get_day(), utils::InputType::Test2).unwrap().as_mut() + ).unwrap().to_string(); + + assert_eq!(answer, "281"); + } +} diff --git a/src/solutions/day02.rs b/src/solutions/day02.rs index 4048635..0c4b067 100644 --- a/src/solutions/day02.rs +++ b/src/solutions/day02.rs @@ -25,3 +25,35 @@ impl Solution for Day02 { impl Day02 { } + + +/// Test from puzzle input +#[cfg(test)] +mod test { + use crate::*; + use super::*; + + #[test] + fn part1() { + let challenge = day02::Day02{}; + + //Complete the Challenge + let answer = challenge.part1( + get_input(challenge.get_day(), utils::InputType::Test1).unwrap().as_mut() + ).unwrap().to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day02::Day02{}; + + //Complete the Challenge + let answer = challenge.part2( + get_input(challenge.get_day(), utils::InputType::Test2).unwrap().as_mut() + ).unwrap().to_string(); + + assert_eq!(answer, "Ready"); + } +} \ No newline at end of file