From 73507b1cb6f1853d0b9ccbc1a6a7973d51a4c6cc Mon Sep 17 00:00:00 2001 From: kingchenc Date: Sat, 23 May 2026 23:41:24 +0200 Subject: [PATCH] test(std_dev): cover period/value accessors + warmup/name metadata Codecov flagged 12 lines in crates/wickra-core/src/indicators/std_dev.rs (file at 89.09%): const accessors period (64-66), value (68-71) and Indicator-impl bodies warmup_period (110-112), name (118-120). None of the existing tests inspected the metadata surface. Add accessors_and_metadata asserting period == 14, warmup_period == 14, name == "StdDev", and value() across both the None (pre-warmup) and Some (post-warmup) branches. std_dev.rs is now at 110/110 lines, no behavioural change. --- crates/wickra-core/src/indicators/std_dev.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/wickra-core/src/indicators/std_dev.rs b/crates/wickra-core/src/indicators/std_dev.rs index bec83f1b..ba1fdd5d 100644 --- a/crates/wickra-core/src/indicators/std_dev.rs +++ b/crates/wickra-core/src/indicators/std_dev.rs @@ -131,6 +131,22 @@ mod tests { assert!(matches!(StdDev::new(0), Err(Error::PeriodZero))); } + /// Cover the const accessors `period` / `value` and the Indicator-impl + /// `warmup_period` / `name` methods (lines 64-71, 110-112, 118-120). + /// Existing tests only inspect numeric outputs of `update` / `batch`. + #[test] + fn accessors_and_metadata() { + let mut sd = StdDev::new(14).unwrap(); + assert_eq!(sd.period(), 14); + assert_eq!(sd.warmup_period(), 14); + assert_eq!(sd.name(), "StdDev"); + assert_eq!(sd.value(), None); + for i in 1..=14 { + sd.update(f64::from(i)); + } + assert!(sd.value().is_some()); + } + #[test] fn reference_value() { // StdDev(3) of [2, 4, 6]: mean = 4, variance = (4+0+4)/3 = 8/3.