Created a set of unit tests each day

This commit is contained in:
Luke Else 2023-12-01 16:33:40 +00:00
parent 5a677ea222
commit 4267b68253
2 changed files with 63 additions and 0 deletions

View File

@ -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");
}
}

View File

@ -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");
}
}