test(smma): cover period/value accessors + warmup/name metadata
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.
This commit is contained in:
@@ -116,6 +116,24 @@ mod tests {
|
|||||||
assert!(matches!(Smma::new(0), Err(Error::PeriodZero)));
|
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]
|
#[test]
|
||||||
fn warmup_then_recurrence() {
|
fn warmup_then_recurrence() {
|
||||||
// SMMA(3): seed = SMA(1,2,3) = 2.0; then (prev*2 + x) / 3.
|
// SMMA(3): seed = SMA(1,2,3) = 2.0; then (prev*2 + x) / 3.
|
||||||
|
|||||||
Reference in New Issue
Block a user