Add test cases for D10

This commit is contained in:
kageru 2019-12-10 14:59:21 +01:00
parent 083356a5ed
commit 558212023d

View File

@ -1,3 +1,5 @@
use std::collections::HashSet;
fn main() {
println!("Hello, world!");
}
@ -6,6 +8,14 @@ fn calculate_angle(x_offset: i32, y_offset: i32) -> f32 {
return ((y_offset as f32).atan2(x_offset as f32).to_degrees() * 1000.0).round();
}
fn parse_input(raw: std::str::Lines) -> HashSet<(i32, i32)> {
unimplemented!()
}
fn part1(asteroids: &HashSet<(i32, i32)>) -> (i32, i32) {
unimplemented!()
}
#[cfg(test)]
mod tests {
use super::*;
@ -21,4 +31,94 @@ mod tests {
assert_eq!(calculate_angle(-2, 2), 135_000.0);
assert_ne!(calculate_angle(1, 1), calculate_angle(3, -3));
}
#[test]
fn test_part_1() {
assert_eq!(
part1(&parse_input(
".#..#
.....
#####
....#
...##"
.lines()
)),
(3, 4)
);
assert_eq!(
part1(&parse_input(
"#.#...#.#.
.###....#.
.#....#...
##.#.#.#.#
....#.#.#.
.##..###.#
..#...##..
..##....##
......#...
.####.###."
.lines()
)),
(1, 2)
);
assert_eq!(
part1(&parse_input(
".#..#..###
####.###.#
....###.#.
..###.##.#
##.##.#.#.
....###..#
..#.#..#.#
#..#.#.###
.##...##.#
.....#.#.."
.lines()
)),
(6, 3)
);
assert_eq!(
part1(&parse_input(
"......#.#.
#..#.#....
..#######.
.#.#.###..
.#..#.....
..#....#.#
#..#....#.
.##.#..###
##...#..#.
.#....####"
.lines()
)),
(5, 8)
);
assert_eq!(
part1(&parse_input(
".#..##.###...#######
##.############..##.
.#.######.########.#
.###.#######.####.#.
#####.##.#.##.###.##
..#####..#.#########
####################
#.####....###.#.#.##
##.#################
#####.##.###..####..
..######..##.#######
####.##.####...##..#
.#####..#.######.###
##...#.##########...
#.##########.#######
.####.#.###.###.#.##
....##.##.###..#####
.#.#.###########.###
#.#.#.#####.####.###
###.##.####.##.#..##"
.lines()
)),
(11, 13)
);
}
}