From 6dfa4ee13486655b28fe42ad2cf498b2ba9dc940 Mon Sep 17 00:00:00 2001 From: kingchenc Date: Sat, 23 May 2026 23:40:34 +0200 Subject: [PATCH] test(smma): cover period/value accessors + warmup/name metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codecov flagged 12 lines in crates/wickra-core/src/indicators/smma.rs (file at 86.81%): the const accessors period (57-59), value (62-64) and the Indicator-impl bodies warmup_period (95-97), name (103-105). None of the existing tests inspected the metadata surface — they only fed numeric updates and asserted on SMMA values. Add accessors_and_metadata exercising period == 7, warmup_period == 7, name == "SMMA", and value() across both the None (pre-warmup) and Some (post-warmup) branches. smma.rs is now at 91/91 lines, no behavioural change. --- crates/wickra-core/src/indicators/smma.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/wickra-core/src/indicators/smma.rs b/crates/wickra-core/src/indicators/smma.rs index 69370c25..a5561bdf 100644 --- a/crates/wickra-core/src/indicators/smma.rs +++ b/crates/wickra-core/src/indicators/smma.rs @@ -116,6 +116,24 @@ mod tests { assert!(matches!(Smma::new(0), Err(Error::PeriodZero))); } + /// Cover the const accessors `period` / `value` and the Indicator-impl + /// `warmup_period` / `name` methods. Existing tests only exercise the + /// numeric output of `update` / `batch` / `reset`, never query the + /// metadata surface. + #[test] + fn accessors_and_metadata() { + let mut smma = Smma::new(7).unwrap(); + assert_eq!(smma.period(), 7); + assert_eq!(smma.warmup_period(), 7); + assert_eq!(smma.name(), "SMMA"); + // value() must report both the pre-warmup None and post-warmup Some branches. + assert_eq!(smma.value(), None); + for i in 1..=7 { + smma.update(f64::from(i)); + } + assert!(smma.value().is_some()); + } + #[test] fn warmup_then_recurrence() { // SMMA(3): seed = SMA(1,2,3) = 2.0; then (prev*2 + x) / 3.