test: 100% coverage for mom + sma + stoch_rsi + tema + trima (#25)

* test(mom): cover period/value accessors + name metadata

Codecov flagged 9 lines in indicators/mom.rs (file at 89.53%): const
accessors period (56-58), value (61-63) and Indicator-impl name
(101-103). mom.rs now at 86/86.

* test(sma): cover period accessor + warmup/name metadata

Codecov flagged 9 lines in indicators/sma.rs (file at 93.12%): const
accessor period (70-72), Indicator-impl warmup_period (115-117),
name (123-125). sma.rs now at 131/131.

* test(stoch_rsi): cover periods/value accessors + name metadata

Codecov flagged 9 lines in indicators/stoch_rsi.rs (file at 92.37%):
const accessors periods (69-71), value (74-76) and Indicator-impl
name (131-133). stoch_rsi.rs now at 118/118.

* test(tema): cover period accessor + warmup/name metadata

Codecov flagged 9 lines in indicators/tema.rs (file at 83.63%): const
accessor period (45-47), Indicator-impl warmup_period (67-69), name
(75-77). tema.rs now at 55/55.

* test(trima): cover period/value accessors + name metadata

Codecov flagged 9 lines in indicators/trima.rs (file at 89.53%): const
accessors period (59-61), value (64-66) and Indicator-impl name
(99-101). trima.rs now at 86/86.
This commit is contained in:
kingchenc
2026-05-24 00:47:43 +02:00
committed by GitHub
parent 5a6689cf1a
commit 645b002958
5 changed files with 68 additions and 0 deletions
@@ -112,6 +112,21 @@ mod tests {
assert!(matches!(Trima::new(0), Err(Error::PeriodZero)));
}
/// Cover the const accessors `period` / `value` (59-66) and the
/// Indicator-impl `name` body (99-101). Existing tests inspect
/// TRIMA output but never query the metadata.
#[test]
fn accessors_and_metadata() {
let mut t = Trima::new(5).unwrap();
assert_eq!(t.period(), 5);
assert_eq!(t.name(), "TRIMA");
assert_eq!(t.value(), None);
for i in 1..=t.warmup_period() {
t.update(f64::from(u32::try_from(i).unwrap()));
}
assert!(t.value().is_some());
}
#[test]
fn odd_period_reference_values() {
// TRIMA(5) is SMA(3) of SMA(3).