Add test cases for real inputs
This commit is contained in:
Родитель
fbacd70a6a
Коммит
fb5c023961
|
@ -3,7 +3,7 @@ use std::fmt::Display;
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! aoc_setup {
|
||||
($type:ident $(, test $index:literal: $test_result:expr)*) => {
|
||||
($type:ident $(, $test_type:ident $index:literal: $test_result:expr)*) => {
|
||||
// TODO: pub use another macro that creates benchmarks?
|
||||
|
||||
fn main() {
|
||||
|
@ -11,16 +11,29 @@ macro_rules! aoc_setup {
|
|||
}
|
||||
|
||||
$(
|
||||
aoc_lib::paste! {
|
||||
#[test]
|
||||
fn [<solve_sample_part_ $index>]() {
|
||||
let input = include_str!("../sample.txt");
|
||||
let parsed = $type::parse_input(input);
|
||||
assert_eq!($test_result, $type::[< solve_ $index >](&parsed));
|
||||
}
|
||||
}
|
||||
aoc_setup!(test_impl $test_type $type $index: $test_result);
|
||||
)*
|
||||
};
|
||||
(test_impl sample $type:ident $index:literal: $test_result:expr) => {
|
||||
aoc_lib::paste! {
|
||||
#[test]
|
||||
fn [<solve_sample_part_ $index>]() {
|
||||
let input = include_str!("../sample.txt");
|
||||
let parsed = $type::parse_input(input);
|
||||
assert_eq!($test_result, $type::[< solve_ $index >](&parsed));
|
||||
}
|
||||
}
|
||||
};
|
||||
(test_impl part $type:ident $index:literal: $test_result:expr) => {
|
||||
aoc_lib::paste! {
|
||||
#[test]
|
||||
fn [<solve_part_ $index>]() {
|
||||
let input = include_str!("../input.txt");
|
||||
let parsed = $type::parse_input(input);
|
||||
assert_eq!($test_result, $type::[< solve_ $index >](&parsed));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub trait AdventOfCode {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use aoc_lib::*;
|
||||
|
||||
aoc_setup!(Day1, test 1: 7, test 2: 5);
|
||||
aoc_setup!(Day1, sample 1: 7, sample 2: 5, part 1: 1759, part 2: 1805);
|
||||
|
||||
pub struct Day1;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use aoc_lib::*;
|
||||
|
||||
aoc_setup!(Day2, test 1: 150, test 2: 900);
|
||||
aoc_setup!(Day2, sample 1: 150, sample 2: 900, part 1: 1654760, part 2: 1956047400);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Direction {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use aoc_lib::*;
|
||||
|
||||
aoc_setup!(Day3, test 1: 198, test 2: 230);
|
||||
aoc_setup!(Day3, sample 1: 198, sample 2: 230, part 1: 4191876, part 2: 3414905);
|
||||
|
||||
pub struct Day3;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use aoc_lib::*;
|
|||
use itertools::Itertools;
|
||||
use std::ops::IndexMut;
|
||||
|
||||
aoc_setup!(Day4, test 1: 4512, test 2: 1924);
|
||||
aoc_setup!(Day4, sample 1: 4512, sample 2: 1924, part 1: 16674, part 2: 7075);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Input(Vec<u8>, Vec<Board>);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use aoc_lib::*;
|
||||
|
||||
aoc_setup!(Day5, test 1: 5, test 2: 12000);
|
||||
aoc_setup!(Day5, sample 1: 5, sample 2: 12, part 1: 4826, part 2: 16793);
|
||||
|
||||
pub struct Day5;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче