test(mutants): all first-party crates in scope; config boundary tests catch the missed mutants
395ad226cd039ecfb3ecb3223c050c91bc98e4cc
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: 4980d065480b
There are many coding harnesses - but this one is fast
395ad226cd039ecfb3ecb3223c050c91bc98e4cc
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+98 / −0 text lines
+98 / −0 text lines
#[cfg(test)]mod tests { use super::*; fn with_max_frame_bytes(value: usize) -> Config { let mut config = Config::default_valid(); config.max_frame_bytes = value; config } fn with_tool_timeout_ms(value: u64) -> Config { let mut config = Config::default_valid(); config.tool_timeout_ms = value; config } /// `max_frame_bytes < MIN_FRAME_BYTES` is the only rejection; the bound /// itself, and one step above it, are both accepted. #[test] fn max_frame_bytes_lower_bound_is_inclusive() { assert!( with_max_frame_bytes(MIN_FRAME_BYTES - 1) .validate() .is_err() ); assert!(with_max_frame_bytes(MIN_FRAME_BYTES).validate().is_ok()); assert!(with_max_frame_bytes(MIN_FRAME_BYTES + 1).validate().is_ok()); } /// `max_frame_bytes > MAX_FRAME_BYTES` is the only rejection; the bound /// itself, and one step below it, are both accepted. #[test] fn max_frame_bytes_upper_bound_is_inclusive() { assert!(with_max_frame_bytes(MAX_FRAME_BYTES - 1).validate().is_ok()); assert!(with_max_frame_bytes(MAX_FRAME_BYTES).validate().is_ok()); assert!( with_max_frame_bytes(MAX_FRAME_BYTES + 1) .validate() .is_err() ); } /// `tool_timeout_ms < MIN_TOOL_TIMEOUT_MS` is the only rejection; the /// bound itself, and one step above it, are both accepted. #[test] fn tool_timeout_ms_lower_bound_is_inclusive() { assert!( with_tool_timeout_ms(MIN_TOOL_TIMEOUT_MS - 1) .validate() .is_err() ); assert!(with_tool_timeout_ms(MIN_TOOL_TIMEOUT_MS).validate().is_ok()); assert!( with_tool_timeout_ms(MIN_TOOL_TIMEOUT_MS + 1) .validate() .is_ok() ); } /// Pins the exact scale factor so a `*` mutated to `+` (or a swapped /// operand) changes the default instead of surviving unnoticed. #[test] fn default_max_frame_bytes_is_the_lower_bound_scaled_by_1024() { assert_eq!( Config::default_valid().max_frame_bytes, MIN_FRAME_BYTES * 1024 ); } /// A literal, not an expression built from the same operators, so a /// `*` mutated to `+` in the constant's own definition cannot cancel /// out against an identically mutated expectation. #[test] fn max_frame_bytes_upper_bound_is_100_mebibytes() { assert_eq!(MAX_FRAME_BYTES, 104_857_600); } /// `auth_dir` composes a directory, always ending in `auth` under a /// `smith` (or, lacking a platform data directory, `.smith`) base; it /// is never the empty default `PathBuf`. #[test] fn auth_dir_ends_with_smith_auth_segments() { let dir = auth_dir(); assert_eq!(dir.file_name(), Some(std::ffi::OsStr::new("auth"))); let base = dir.parent().expect("auth_dir has a parent"); let base_name = base.file_name().expect("base has a name"); assert!( base_name == "smith" || base_name == ".smith", "unexpected auth dir base: {}", base.display() ); }}