From a69d40fc5dcbe2e3e51d4e1096e464d9f010c58b Mon Sep 17 00:00:00 2001 From: Isaac Corbrey Date: Thu, 4 Dec 2025 10:06:41 -0500 Subject: [PATCH] [wip] day 4: Unload the printing department --- ...4_printing_department.proptest-regressions | 7 ++ examples/day_04_printing_department.rs | 76 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 examples/day_04_printing_department.proptest-regressions create mode 100644 examples/day_04_printing_department.rs diff --git a/examples/day_04_printing_department.proptest-regressions b/examples/day_04_printing_department.proptest-regressions new file mode 100644 index 0000000..595d307 --- /dev/null +++ b/examples/day_04_printing_department.proptest-regressions @@ -0,0 +1,7 @@ +# Seeds for failure cases proptest has generated in the past. It is +# automatically read and these particular cases re-run before any +# novel cases are generated. +# +# It is recommended to check this file in to source control so that +# everyone who runs the test benefits from these saved cases. +cc 2ede2633c7d67ab5e546e5c8c737e0b2a7033d69097fce43336250232de3eebb # shrinks to ch = ' ' diff --git a/examples/day_04_printing_department.rs b/examples/day_04_printing_department.rs new file mode 100644 index 0000000..5b2a0fc --- /dev/null +++ b/examples/day_04_printing_department.rs @@ -0,0 +1,76 @@ +fn main() {} + +#[derive(Debug)] +struct Position { + x: u32, + y: u32, +} + +fn is_paper_roll(ch: char) -> bool { + ch == '@' +} + +fn parse_line(line: &str, y: u32) -> Vec { + vec![] +} + +fn parse_input(input: &str) -> Vec { + vec![] +} + +#[cfg(test)] +mod test { + use super::*; + use proptest::prelude::*; + + mod is_paper_roll { + use super::*; + + proptest! { + #[test] + fn doesnt_crash(ch in any::()) { + is_paper_roll(ch); + } + } + + #[test] + fn accepts_at_signs() { + assert!(is_paper_roll('@')); + } + + proptest! { + #[test] + fn rejects_not_at_signs(ch in any::().prop_filter("cannot be @", |ch| ch != &'@')) { + prop_assert!(!is_paper_roll(ch)) + } + } + } + + prop_compose! { + fn line(y: u32)(xs in prop::collection::vec(0_u32..100, 10..50)) -> Vec { + xs.iter().map(|x| Position { x: *x, y }).collect::>() + } + } + + mod parse_line { + use super::*; + + // proptest! { + // #[test] + // fn doesnt_crash(s in line(y), y in any::()) { + // parse_line(&s, y); + // } + // } + } + + mod parse_input { + use super::*; + + proptest! { + #[test] + fn doesnt_crash(s in "\\PC+") { + parse_input(&s); + } + } + } +} -- 2.51.2