mirror of
https://github.com/Noratrieb/advent-of-code.git
synced 2026-01-14 09:35:01 +01:00
tests
This commit is contained in:
parent
b093225df0
commit
7be7e7c549
3 changed files with 52 additions and 36 deletions
|
|
@ -55,6 +55,40 @@ pub fn test_part2<D: Day>(inputs: &[(&str, u64)]) {
|
|||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! tests {
|
||||
(
|
||||
$day_small:ident $day:ident;
|
||||
part1 {
|
||||
small => $p1small:expr;
|
||||
default => $p1default:expr;
|
||||
}
|
||||
part2 {
|
||||
small => $p2small:expr;
|
||||
default => $p2default:expr;
|
||||
}
|
||||
) => {
|
||||
#[cfg(test)]
|
||||
mod $day_small {
|
||||
#[test]
|
||||
fn part1() {
|
||||
helper::test_part1::<super::$day>(&[
|
||||
(include_str!("../input_small.txt"), $p1small),
|
||||
(include_str!("../input.txt"), $p1default),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
helper::test_part2::<super::$day>(&[
|
||||
(include_str!("../input_small.txt"), $p2small),
|
||||
(include_str!("../input.txt"), $p2default),
|
||||
]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn integer(input: &str) -> IResult<&str, u64> {
|
||||
map(digit1, |d: &str| d.parse::<u64>().unwrap())(input)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue