Move imports into macros
This commit is contained in:
parent
250bad526c
commit
731d7f5e33
|
@ -36,8 +36,6 @@ fn main() {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use aoc2021::*;
|
use aoc2021::*;
|
||||||
use paste::paste;
|
|
||||||
use test::black_box;
|
|
||||||
|
|
||||||
const TEST_INPUT: &str = "";
|
const TEST_INPUT: &str = "";
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use aoc2021::common::{parse_nums, *};
|
||||||
type Parsed = Vec<usize>;
|
type Parsed = Vec<usize>;
|
||||||
|
|
||||||
fn read_input() -> String {
|
fn read_input() -> String {
|
||||||
read_file(01)
|
read_file(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_input(raw: &str) -> Parsed {
|
fn parse_input(raw: &str) -> Parsed {
|
||||||
|
@ -31,8 +31,6 @@ fn main() {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use aoc2021::*;
|
use aoc2021::*;
|
||||||
use paste::paste;
|
|
||||||
use test::black_box;
|
|
||||||
|
|
||||||
const TEST_INPUT: &str = "199
|
const TEST_INPUT: &str = "199
|
||||||
200
|
200
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! bench {
|
macro_rules! bench {
|
||||||
($part: ident ($($param: expr),*) == $expected:expr) => {
|
($part: ident ($($param: expr),*) == $expected:expr) => {
|
||||||
paste! {
|
paste::paste! {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn [<$part _bench>](b: &mut test::Bencher) {
|
fn [<$part _bench>](b: &mut test::Bencher) {
|
||||||
let raw = &read_input();
|
let raw = &read_input();
|
||||||
let input = parse_input(&raw);
|
let input = parse_input(&raw);
|
||||||
b.iter(|| assert_eq!($part(black_box(&input)$(, $param)*), $expected));
|
b.iter(|| assert_eq!($part(test::black_box(&input)$(, $param)*), $expected));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ macro_rules! bench_input {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_input_parsing(b: &mut test::Bencher) {
|
fn bench_input_parsing(b: &mut test::Bencher) {
|
||||||
let raw = read_input();
|
let raw = read_input();
|
||||||
b.iter(|| assert_eq!(parse_input(black_box(&raw)).$fn(), $expected_len));
|
b.iter(|| assert_eq!(parse_input(test::black_box(&raw)).$fn(), $expected_len));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ macro_rules! bench_input {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! test {
|
macro_rules! test {
|
||||||
($part: ident ($($param: expr),*) == $expected:expr) => {
|
($part: ident ($($param: expr),*) == $expected:expr) => {
|
||||||
paste! {
|
paste::paste! {
|
||||||
#[test]
|
#[test]
|
||||||
fn [<$part _test>]() {
|
fn [<$part _test>]() {
|
||||||
let input = parse_input(TEST_INPUT);
|
let input = parse_input(TEST_INPUT);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user