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
+14
View File
@@ -131,6 +131,20 @@ mod tests {
use crate::traits::BatchExt;
use approx::assert_relative_eq;
/// Cover the `periods` accessor (65-67) and the Indicator-impl
/// `warmup_period` (115-117) + `name` (123-125). Existing tests
/// inspect KAMA output but never query the metadata.
#[test]
fn accessors_and_metadata() {
let k = Kama::classic();
let (er, fast, slow) = k.periods();
assert_eq!(er, 10);
assert!((fast - 2.0 / (2.0 + 1.0)).abs() < 1e-12);
assert!((slow - 2.0 / (30.0 + 1.0)).abs() < 1e-12);
assert_eq!(k.warmup_period(), 11);
assert_eq!(k.name(), "KAMA");
}
#[test]
fn constant_series_yields_constant_kama() {
let mut k = Kama::classic();