test: 100% coverage for ema + historical_volatility + kama + linreg_angle + mass_index (#24)

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

Codecov flagged 9 lines in crates/wickra-core/src/indicators/ema.rs
(file at 94.03%): const accessor period (74-77), Indicator-impl
warmup_period (123-125), name (131-133). ema.rs now at 151/151.

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

Codecov flagged 9 lines in crates/wickra-core/src/indicators/historical_volatility.rs
(file at 93.87%): const accessors periods (80-83), value (85-88) and
Indicator-impl name (153-155). historical_volatility.rs now at 147/147.

* test(kama): cover periods accessor + warmup/name metadata

Codecov flagged 9 lines in crates/wickra-core/src/indicators/kama.rs
(file at 91.26%): accessor periods (65-67), Indicator-impl
warmup_period (115-117), name (123-125). kama.rs now at 103/103.

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

Codecov flagged 9 lines in crates/wickra-core/src/indicators/linreg_angle.rs
(file at 88.15%): const accessor period (50-52), Indicator-impl
warmup_period (67-69), name (75-77). linreg_angle.rs now at 76/76.

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

Codecov flagged 9 lines in crates/wickra-core/src/indicators/mass_index.rs
(file at 91.42%): const accessors periods (80-82), value (85-87) and
Indicator-impl name (134-136). mass_index.rs now at 105/105.
This commit is contained in:
kingchenc
2026-05-24 00:48:35 +02:00
committed by GitHub
parent d55d3db3d1
commit adc8488939
5 changed files with 67 additions and 0 deletions
+12
View File
@@ -165,6 +165,18 @@ mod tests {
assert!(matches!(Ema::new(0), Err(Error::PeriodZero)));
}
/// Cover the const accessor `period` (74-77) and the Indicator-impl
/// `warmup_period` (123-125) + `name` (131-133). `alpha` and `value`
/// are exercised by other tests and downstream consumers; only the
/// three metadata methods were dead.
#[test]
fn accessors_and_metadata() {
let ema = Ema::new(14).unwrap();
assert_eq!(ema.period(), 14);
assert_eq!(ema.warmup_period(), 14);
assert_eq!(ema.name(), "EMA");
}
#[test]
fn warmup_returns_none_until_seed() {
let mut ema = Ema::new(3).unwrap();