From 0667ca29ad7c2b6601f08cae4c4ef80156c2200f Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 1 Dec 2021 07:34:50 +0100 Subject: [PATCH] 2021: day01 tests --- aoc2021/input/day01_provided.txt | 10 ++++++++++ aoc2021/src/day01.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 aoc2021/input/day01_provided.txt diff --git a/aoc2021/input/day01_provided.txt b/aoc2021/input/day01_provided.txt new file mode 100644 index 0000000..167e291 --- /dev/null +++ b/aoc2021/input/day01_provided.txt @@ -0,0 +1,10 @@ +199 +200 +208 +210 +200 +207 +240 +269 +260 +263 diff --git a/aoc2021/src/day01.rs b/aoc2021/src/day01.rs index ba6765e..26f40b3 100644 --- a/aoc2021/src/day01.rs +++ b/aoc2021/src/day01.rs @@ -43,3 +43,30 @@ fn part2(input: &str) -> Result { Ok(increases) } + +#[cfg(test)] +mod tests { + use super::*; + + const PROVIDED: &str = include_str!("../input/day01_provided.txt"); + + #[test] + fn part1_provided() { + assert_eq!(part1(PROVIDED).unwrap(), 7); + } + + #[test] + fn part1_real() { + assert_eq!(part1(INPUT).unwrap(), 1502); + } + + #[test] + fn part2_provided() { + assert_eq!(part2(PROVIDED).unwrap(), 5); + } + + #[test] + fn part2_real() { + assert_eq!(part2(INPUT).unwrap(), 1538); + } +}