diff --git a/crates/weksa/src/split.rs b/crates/weksa/src/split.rs index d22d3db..20f971d 100644 --- a/crates/weksa/src/split.rs +++ b/crates/weksa/src/split.rs @@ -172,6 +172,9 @@ impl Checkpoint { } } +#[cfg(test)] +mod mutants; + /// Item builders for the unit tests that live in `src`: the twins of /// `tests/common`'s `group_in_bucket`, `item_in`, `cast` and `model`. #[cfg(test)] diff --git a/crates/weksa/src/split/mutants.rs b/crates/weksa/src/split/mutants.rs new file mode 100644 index 0000000..99cde9f --- /dev/null +++ b/crates/weksa/src/split/mutants.rs @@ -0,0 +1,11 @@ +//! Pins of private items of `split` found unpinned by mutation testing. + +use super::Checkpoint; + +/// A checkpoint reports the round it was declared at, whatever the round. +#[test] +fn a_checkpoint_reports_its_round() { + assert_eq!(Checkpoint::for_test(7).round(), 7); + assert_eq!(Checkpoint::for_test(0).round(), 0); + assert_eq!(Checkpoint::for_test(1).round(), 1); +} diff --git a/crates/weksa/tests/mutants_a.rs b/crates/weksa/tests/mutants_a.rs new file mode 100644 index 0000000..a9ddda5 --- /dev/null +++ b/crates/weksa/tests/mutants_a.rs @@ -0,0 +1,25 @@ +//! Pins for behaviour of the small and middle weksa files that mutation testing +//! found unpinned. Each test states the behaviour in domain terms. + +use weksa::form::is_calendar_date; + +/// A calendar date is exactly `YYYY-MM-DD`: both hyphens sit where the format +/// puts them, so a ten-byte string with a digit in the second hyphen's place is +/// no date. +#[test] +fn a_calendar_date_needs_both_hyphens_in_place() { + assert!(is_calendar_date("2026-01-01")); + assert!(!is_calendar_date("2026-01201")); + assert!(!is_calendar_date("2026101-01")); +} + +/// February has 29 days in a Gregorian leap year and 28 otherwise. +#[test] +fn february_has_29_days_only_in_gregorian_leap_years() { + assert!(is_calendar_date("2024-02-29")); + assert!(is_calendar_date("2000-02-29")); + assert!(!is_calendar_date("1900-02-29")); + assert!(!is_calendar_date("2023-02-29")); + assert!(is_calendar_date("2023-02-28")); + assert!(!is_calendar_date("2024-02-30")); +}