1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Solutions for [Advent of Code].
//!
//!  [Advent of Code]: http://adventofcode.com/about

#![feature(conservative_impl_trait)]
#![feature(try_from)]

extern crate itertools;
extern crate reqwest;
#[macro_use] extern crate nom;

mod download;
pub use download::Downloader;

#[macro_use] pub mod parse;

pub mod iter;

mod direction;
pub use direction::Direction;

macro_rules! test_day {
    ($day:expr, $part1:expr, $part2:expr) => (
        #[cfg(test)]
        mod tests {
            #[test]
            fn parse() {
                super::parse_input(
                    include_str!(concat!("../../test_inputs/2017/", $day))
                );
            }

            #[test]
            fn part1() {
                let input = super::parse_input(
                    include_str!(concat!("../../test_inputs/2017/", $day))
                );

                assert_eq!(super::part1(&input), $part1);
            }

            #[test]
            fn part2() {
                let input = super::parse_input(
                    include_str!(concat!("../../test_inputs/2017/", $day))
                );

                assert_eq!(super::part2(&input), $part2);
            }
        }
    )
}

macro_rules! test_day_both {
    ($day:expr, $part1:expr, $part2:expr) => (
        #[cfg(test)]
        mod tests {
            #[test]
            fn parse() {
                super::parse_input(
                    include_str!(concat!("../../test_inputs/2017/", $day))
                );
            }

            #[test]
            fn solve() {
                let input = super::parse_input(
                    include_str!(concat!("../../test_inputs/2017/", $day))
                );
                let (part1, part2) = super::solve(&input);

                assert_eq!(part1, $part1);
                assert_eq!(part2, $part2);
            }
        }
    )
}

pub mod advent2017;