test: 100% coverage for tsi + ultimate_oscillator + vortex + vwma + zlema (#26)

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

Codecov flagged 9 lines in indicators/tsi.rs (file at 92.30%): const
accessors periods (70-72), value (75-77) and Indicator-impl name
(137-139). tsi.rs now at 117/117.

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

Codecov flagged 9 lines in indicators/ultimate_oscillator.rs
(file at 94.76%): const accessors periods (96-98), value (101-103)
and Indicator-impl name (193-195). uo.rs now at 172/172.

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

Codecov flagged 9 lines in indicators/vortex.rs (file at 93.18%): const
accessors period (84-86), value (89-91) and Indicator-impl name
(157-159). vortex.rs now at 132/132.

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

Codecov flagged 9 lines in indicators/vwma.rs (file at 92.56%): const
accessors period (72-74), value (77-79) and Indicator-impl name
(129-131). vwma.rs now at 121/121.

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

Codecov flagged 9 lines in indicators/zlema.rs (file at 90.62%): const
accessors period (62-64), value (72-74) and Indicator-impl name
(111-113). zlema.rs now at 96/96.
This commit is contained in:
kingchenc
2026-05-24 00:47:46 +02:00
committed by GitHub
parent 645b002958
commit a5d4926718
5 changed files with 90 additions and 0 deletions
@@ -124,6 +124,21 @@ mod tests {
assert!(matches!(Zlema::new(0), Err(Error::PeriodZero)));
}
/// Cover the const accessors `period` / `value` (62-64, 72-74) and
/// the Indicator-impl `name` body (111-113). `lag` is already covered
/// by `lag_is_half_of_period_minus_one`.
#[test]
fn accessors_and_metadata() {
let mut z = Zlema::new(5).unwrap();
assert_eq!(z.period(), 5);
assert_eq!(z.name(), "ZLEMA");
assert_eq!(z.value(), None);
for i in 1..=z.warmup_period() {
z.update(f64::from(u32::try_from(i).unwrap()));
}
assert!(z.value().is_some());
}
#[test]
fn lag_is_half_of_period_minus_one() {
assert_eq!(Zlema::new(3).unwrap().lag(), 1);