Test are only compiled when testing

This commit is contained in:
Dreaded_X 2022-12-03 04:26:39 +01:00
parent 02e048b421
commit 0f25ef7775
Signed by: Dreaded_X
GPG Key ID: 76BDEC4E165D8AD9
3 changed files with 60 additions and 39 deletions

View File

@ -1,28 +1,35 @@
// -- Setup & Runners --
use anyhow::Result; use anyhow::Result;
use aoc::Solver; use aoc::Solver;
pub struct Day;
// -- Runners --
fn main() -> Result<()> { fn main() -> Result<()> {
Day::solve() Day::solve()
} }
#[test]
fn part1_test1() -> Result<()> { #[cfg(test)]
Day::test(aoc::Part::ONE, "test-1", 24000) mod tests {
} use super::*;
#[test]
fn part2_test1() -> Result<()> { #[test]
Day::test(aoc::Part::TWO, "test-1", 45000) fn part1_test1() -> Result<()> {
} Day::test(aoc::Part::ONE, "test-1", 24000)
#[test] }
fn part1_solution() -> Result<()> { #[test]
Day::test(aoc::Part::ONE, "input", 70116) fn part2_test1() -> Result<()> {
} Day::test(aoc::Part::TWO, "test-1", 45000)
#[test] }
fn part2_solution() -> Result<()> { #[test]
Day::test(aoc::Part::TWO, "input", 206582) fn part1_solution() -> Result<()> {
Day::test(aoc::Part::ONE, "input", 70116)
}
#[test]
fn part2_solution() -> Result<()> {
Day::test(aoc::Part::TWO, "input", 206582)
}
} }
// -- Solution -- // -- Solution --
pub struct Day;
impl aoc::Solver for Day { impl aoc::Solver for Day {
fn day() -> u8 { fn day() -> u8 {
1 1

View File

@ -1,25 +1,31 @@
// -- Setup & Runners --
use anyhow::Result; use anyhow::Result;
use aoc::Solver; use aoc::Solver;
pub struct Day;
// -- Runners --
fn main() -> Result<()> { fn main() -> Result<()> {
Day::solve() Day::solve()
} }
#[test]
fn part1_test1() -> Result<()> { #[cfg(test)]
Day::test(aoc::Part::ONE, "test-1", 15) mod tests {
} use super::*;
#[test]
fn part2_test1() -> Result<()> { #[test]
Day::test(aoc::Part::TWO, "test-1", 12) fn part1_test1() -> Result<()> {
} Day::test(aoc::Part::ONE, "test-1", 15)
#[test] }
fn part1_solution() -> Result<()> { #[test]
Day::test(aoc::Part::ONE, "input", 14264) fn part2_test1() -> Result<()> {
} Day::test(aoc::Part::TWO, "test-1", 12)
#[test] }
fn part2_solution() -> Result<()> { #[test]
Day::test(aoc::Part::TWO, "input", 12382) fn part1_solution() -> Result<()> {
Day::test(aoc::Part::ONE, "input", 14264)
}
#[test]
fn part2_solution() -> Result<()> {
Day::test(aoc::Part::TWO, "input", 12382)
}
} }
// -- Implementation for hand -- // -- Implementation for hand --
@ -102,6 +108,7 @@ fn calc_score(sum: u32, (a, b): (Hand, Hand)) -> u32 {
} }
// -- Solution -- // -- Solution --
pub struct Day;
impl aoc::Solver for Day { impl aoc::Solver for Day {
fn day() -> u8 { fn day() -> u8 {
2 2

View File

@ -1,16 +1,23 @@
// -- Setup & Runners --
use anyhow::Result; use anyhow::Result;
use aoc::Solver; use aoc::Solver;
pub struct Day;
// -- Runners --
fn main() -> Result<()> { fn main() -> Result<()> {
Day::solve() Day::solve()
} }
#[test]
fn part1_test1() -> Result<()> { #[cfg(test)]
Day::test(aoc::Part::ONE, "test-1", 0) mod tests {
use super::*;
#[test]
fn part1_test1() -> Result<()> {
Day::test(aoc::Part::ONE, "test-1", 0)
}
} }
// -- Solution -- // -- Solution --
pub struct Day;
impl aoc::Solver for Day { impl aoc::Solver for Day {
fn day() -> u8 { fn day() -> u8 {
todo!("Day not set") todo!("Day not set")