2021: day02: tests

This commit is contained in:
Antoine Martin 2021-12-02 10:30:09 +01:00
parent 0eed53749c
commit 43c89d10bf
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,6 @@
forward 5
down 5
forward 8
up 3
down 8
forward 2

View file

@ -84,3 +84,30 @@ impl std::str::FromStr for Command {
}) })
} }
} }
#[cfg(test)]
mod tests {
use super::*;
const PROVIDED: &str = include_str!("../input/day02_provided.txt");
#[test]
fn part1_provided() {
assert_eq!(part1(PROVIDED).unwrap(), 150);
}
#[test]
fn part1_real() {
assert_eq!(part1(INPUT).unwrap(), 1962940);
}
#[test]
fn part2_provided() {
assert_eq!(part2(PROVIDED).unwrap(), 900);
}
#[test]
fn part2_real() {
assert_eq!(part2(INPUT).unwrap(), 1813664422);
}
}