2021: day02: tests
This commit is contained in:
parent
0eed53749c
commit
43c89d10bf
6
aoc2021/input/day02_provided.txt
Normal file
6
aoc2021/input/day02_provided.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
forward 5
|
||||
down 5
|
||||
forward 8
|
||||
up 3
|
||||
down 8
|
||||
forward 2
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue