diff --git a/crates/weksa/src/run.rs b/crates/weksa/src/run.rs index 7339a6e..15216d6 100644 --- a/crates/weksa/src/run.rs +++ b/crates/weksa/src/run.rs @@ -3112,6 +3112,9 @@ fn discard_inventory(dir: &Path) { } } +#[cfg(test)] +mod mutants; + #[cfg(test)] mod tests { use super::*; diff --git a/crates/weksa/src/run/mutants.rs b/crates/weksa/src/run/mutants.rs new file mode 100644 index 0000000..75b1e63 --- /dev/null +++ b/crates/weksa/src/run/mutants.rs @@ -0,0 +1,21 @@ +//! Pins for private functions of `run.rs` that the doors reach only through a +//! whole run. + +use super::*; + +/// A line is probed only when it has at least four words, and then it is +/// split in two near its byte middle, the pieces trimmed. +#[test] +fn a_recall_line_splits_from_four_words_and_not_before() { + assert_eq!(recall_split("one two three"), None); + assert_eq!(recall_split(""), None); + assert_eq!( + recall_split("one two three four"), + Some(("one two".to_string(), "three four".to_string())) + ); + // No spaces: each ideograph is a word, the split falls at the middle. + assert_eq!( + recall_split("天地不仁以万物为刍狗"), + Some(("天地不仁以".to_string(), "万物为刍狗".to_string())) + ); +} diff --git a/crates/weksa/tests/mutants_c.rs b/crates/weksa/tests/mutants_c.rs index 5aebcc7..92d55f9 100644 --- a/crates/weksa/tests/mutants_c.rs +++ b/crates/weksa/tests/mutants_c.rs @@ -105,3 +105,11 @@ fn a_panel_language_no_item_carries_is_refused_at_open() { assert!(matches!(create(panel), Err(weksa::run::RunError::Panel)), "{panel:?}"); } } + +/// A run keeps its recall probes in `recall` under its own root. +#[test] +fn a_run_keeps_its_recall_under_its_root() { + let dir = tempfile::tempdir().unwrap(); + let run = common::run_over(dir.path()); + assert_eq!(run.recall_dir(), dir.path().join("run").join("recall")); +}