62 lines
1.4 KiB
Rust
62 lines
1.4 KiB
Rust
use super::template::{DayTrait, ResultType};
|
|
use nom::{error::Error, Err, IResult, Parser};
|
|
use thiserror::Error;
|
|
|
|
const DAY_NUMBER: usize = todo!();
|
|
|
|
pub struct Day;
|
|
|
|
impl DayTrait for Day {
|
|
fn get_day_number(&self) -> usize {
|
|
DAY_NUMBER
|
|
}
|
|
|
|
fn part1(&self, lines: &str) -> anyhow::Result<ResultType> {
|
|
Ok(ResultType::Nothing)
|
|
}
|
|
|
|
fn part2(&self, lines: &str) -> anyhow::Result<ResultType> {
|
|
Ok(ResultType::Nothing)
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Error)]
|
|
enum DayError {
|
|
#[error("Not a valid description: {0}")]
|
|
ParsingError(String),
|
|
}
|
|
|
|
impl From<Err<Error<&str>>> for DayError {
|
|
fn from(error: Err<Error<&str>>) -> Self {
|
|
DayError::ParsingError(error.to_string())
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use super::*;
|
|
use crate::common::file::read_string;
|
|
use anyhow::Result;
|
|
|
|
#[test]
|
|
fn test_part1() -> Result<()> {
|
|
let day = Day {};
|
|
let lines = read_string(day.get_day_number(), "example01.txt")?;
|
|
let expected = ResultType::Nothing;
|
|
let result = day.part1(&lines)?;
|
|
assert_eq!(result, expected);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_part2() -> Result<()> {
|
|
let day = Day {};
|
|
let lines = read_string(day.get_day_number(), "example01.txt")?;
|
|
let expected = ResultType::Nothing;
|
|
let result = day.part2(&lines)?;
|
|
assert_eq!(result, expected);
|
|
|
|
Ok(())
|
|
}
|
|
}
|