From 2a60e05baaf2bbf578c22e08a3f3ba26fc2b3b8c Mon Sep 17 00:00:00 2001 From: kageru Date: Sat, 5 Dec 2020 09:50:09 +0100 Subject: [PATCH] Add tests for 2020/05 --- 2020/05/Cargo.toml | 10 + 2020/05/input | 881 ++++++++++++++++++++++++++++++++++++++++++++ 2020/05/src/main.rs | 56 +++ 2020/setup_day.sh | 7 + 4 files changed, 954 insertions(+) create mode 100644 2020/05/Cargo.toml create mode 100644 2020/05/input create mode 100644 2020/05/src/main.rs diff --git a/2020/05/Cargo.toml b/2020/05/Cargo.toml new file mode 100644 index 0000000..dbf353b --- /dev/null +++ b/2020/05/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day05" +version = "0.1.0" +authors = ["kageru "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +itertools = "0.9.0" diff --git a/2020/05/input b/2020/05/input new file mode 100644 index 0000000..3de3f81 --- /dev/null +++ b/2020/05/input @@ -0,0 +1,881 @@ +FFBBBFFLRL +BFFBFBFRLR +FFFBBFBRRR +BFFBBBBRRL +FFFBBFBLLR +BBFBFBFLLR +FBBFFBFLRL +BFBFBBFLLL +FBFBBFBLRR +FFFBBBBRLR +FFFFBFFRRL +BFFFBFBLRL +BBFFFBBRLL +FFBFFFBLRL +FBFBFFFRLL +BFFBBBFRRL +BFFFBBFRLR +BBBFFFBRLL +FBBBFFBRLL +FFFBFFBRLL +BBFBFBFLLL +BFFBFFFLRL +BBFBBFFLRL +FBFBBBFRRR +FBBBBFBRRL +FBBFFFFLRL +FFFBBFBLRL +BFFFFFFLLR +FFBFFBBRRR +FFFFBBBRLR +FFFBFFFLRR +FBBFBBFLLL +FBBFBBBRLR +BFFBFFFLLR +FFBFBFFRLL +FFFFBBFLRR +BBFBBBFLRR +BFBFBBBRLR +BFFBBFFLRL +BFFBFFFLLL +FBFFFBFLRR +FFFBBBFRLR +FBBFBBFRLL +BBFFFBBLLL +BBFFFFFLLL +FBFF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BFFBBBLRR +FFFFBFBRLR +FBFBFBBLRR +BFBBFFFRRR +FBFBFBFLRL +FBBBFBBRLR +FFBBBFFRRL +FBFFFBBRLL +BBFFBFBLRL +BBFFFBBLRR +BFFBBBFRRR +BBFBFFFRLL +FFBBBBFLRR +FBFFBBFLLR +BFFFFBFLRR +FBFBBBFLLR +FFFBFBFLLR +FFBBFBBRLR +BBFBBFFRRL +BBFFBBFLLR +FFBFFBFLRR +FBFFBBBRRR +BFBFBBBRLL +FFBBFBFLRR +BFFBBFFRLL +BFFFFFFRLR +BBBFFFBRLR +BFBBBFBLLR +FBFFFFBLLR +FFFFBFBLRR +FBBBFBFRLL +FFBFBFBRRR +BBFFFBFLRL +FFBFFFFLRR +BBFBFBBRLL +BBFBFBFRLL +FBBBBFFLRL +BFFFBFBRLL +FFFFBFBLLR +FBBFFFBLRL +FBBBBFFLLL +BFBBFBBLRR +FBFBFFFRRL +FBBBFFFLLL +FBBBFBFRLR +BBFBBFBLRR +FBBFBBFRRR +FFBBBBBRRL +FFFBBBFRLL +BFFBBFFLLR +BFBBBFFRLL +BBFFFBBRRL +BFBBFBBRLL +BFBFBFFRRL +BFFBFBFLRR +FFBFBFBLLL +BBFFFBBLRL +BFBFBBFLRR +BBFBBFFLLL +BFFFFFFRRR +BFBBBBFRLL +FBBFBBFLRR +BFBFFBFRLL +FFBBFBBLRR +BFFBBFBRLL +BFBFFBFLRL +FFFBFBBLRR +BFBBBFBRRR +FFFFBFBLLL +FFBFBFFRLR +FFFFBBFLLL +FBFBBFFRRR +BBFFFFFRLL +BFBFBFFLLR +FFBBFFFLLR +FFBFFFFRLR +BFBBBFFRLR +BFFBBFFLRR +FBBFFFBRLL +FFBBBBBRLL +FFBFFBBLLR +FFFFBFBRRL +BFFBFBFLLL +FBBFBBBLRL +BBFBBFBRRL +FFBBBBFLRL +BFFFBBFLLR +FFFBFBFRLL +FFFBBBBRRR +FBFBBBFRRL +BFFFBBBRLR diff --git a/2020/05/src/main.rs b/2020/05/src/main.rs new file mode 100644 index 0000000..eb1ca3b --- /dev/null +++ b/2020/05/src/main.rs @@ -0,0 +1,56 @@ +#![feature(test)] +extern crate test; + +#[derive(Debug, PartialEq)] +struct Position { + row: usize, + col: usize, +} + +fn get_position(pass: &str) -> Position { + unimplemented!(); +} + +fn calculate_id(p: &Position) -> usize { + unimplemented!(); +} + +fn main() { + println!("Hello, world!"); +} + +fn read_input() -> String { + std::fs::read_to_string("input").unwrap() +} + +#[cfg(test)] +mod tests { + use super::*; + use test::black_box; + + const PASS_1: &str = "BFFFBBFRRR"; + const PASS_2: &str = "FFFBBBFRRR"; + const PASS_3: &str = "BBFFBBFRLL"; + + const POS_1: Position = Position { row: 70, col: 7 }; + const POS_2: Position = Position { row: 14, col: 7 }; + const POS_3: Position = Position { row: 102, col: 4 }; + + const SID_1: usize = 567; + const SID_2: usize = 119; + const SID_3: usize = 820; + + #[test] + fn test_get_position() { + assert_eq!(get_position(PASS_1), POS_1); + assert_eq!(get_position(PASS_2), POS_2); + assert_eq!(get_position(PASS_3), POS_3); + } + + #[test] + fn test_calculate_id() { + assert_eq!(calculate_id(&POS_1), SID_1); + assert_eq!(calculate_id(&POS_2), SID_2); + assert_eq!(calculate_id(&POS_3), SID_3); + } +} diff --git a/2020/setup_day.sh b/2020/setup_day.sh index cc5d755..f07c213 100755 --- a/2020/setup_day.sh +++ b/2020/setup_day.sh @@ -14,4 +14,11 @@ sed -i -e '$a\' input echo 'fn read_input() -> String { std::fs::read_to_string("input").unwrap() +} + +#[cfg(test)] +mod tests { + use super::*; + use test::black_box; + }' >> src/main.rs