test: 100% coverage for chaikin_volatility + chande_kroll_stop + chandelier_exit + choppiness_index + force_index (#29)

* test(chaikin_volatility): cover periods accessor + name metadata

Codecov flagged 6 lines (file at 94.91%): periods (69-71) + name (99-101).

* test(chande_kroll_stop): cover params accessor + name metadata

Codecov flagged 6 lines (file at 95.45%): params (97-99) + name (164-166).

* test(chandelier_exit): cover params accessor + name metadata

Codecov flagged 6 lines (file at 95.12%): params (83-85) + name (128-130).

* test(choppiness_index): cover period accessor + name metadata

Codecov flagged 6 lines (file at 95.04%): period (73-75) + name (125-127).

* test(force_index): cover period accessor + name metadata

Codecov flagged 6 lines (file at 93.33%): period (58-60) + name (93-95).
This commit is contained in:
kingchenc
2026-05-24 00:47:56 +02:00
committed by GitHub
parent d9a1950007
commit 8f6ffe5a62
5 changed files with 50 additions and 0 deletions
@@ -189,6 +189,15 @@ mod tests {
assert!(ChaikinVolatility::new(10, 0).is_err());
}
/// Cover the const accessor `periods` (69-71) and the Indicator-impl
/// `name` body (99-101). `warmup_period` is exercised elsewhere.
#[test]
fn accessors_and_metadata() {
let cv = ChaikinVolatility::new(10, 10).unwrap();
assert_eq!(cv.periods(), (10, 10));
assert_eq!(cv.name(), "ChaikinVolatility");
}
#[test]
fn reset_clears_state() {
let candles: Vec<Candle> = (0..40)
@@ -214,6 +214,18 @@ mod tests {
assert!(ChandeKrollStop::new(10, f64::NAN, 9).is_err());
}
/// Cover the const accessor `params` (97-99) and the Indicator-impl
/// `name` body (164-166). `warmup_period` is exercised elsewhere.
#[test]
fn accessors_and_metadata() {
let s = ChandeKrollStop::new(10, 1.0, 9).unwrap();
let (p, m, q) = s.params();
assert_eq!(p, 10);
assert!((m - 1.0).abs() < 1e-12);
assert_eq!(q, 9);
assert_eq!(s.name(), "ChandeKrollStop");
}
#[test]
fn reset_clears_state() {
let candles: Vec<Candle> = (0..40)
@@ -197,6 +197,17 @@ mod tests {
assert!(ChandelierExit::new(22, f64::NAN).is_err());
}
/// Cover the const accessor `params` (83-85) and the Indicator-impl
/// `name` body (128-130). `warmup_period` is exercised elsewhere.
#[test]
fn accessors_and_metadata() {
let ce = ChandelierExit::new(22, 3.0).unwrap();
let (p, m) = ce.params();
assert_eq!(p, 22);
assert!((m - 3.0).abs() < 1e-12);
assert_eq!(ce.name(), "ChandelierExit");
}
#[test]
fn reset_clears_state() {
let candles: Vec<Candle> = (0..40)
@@ -191,6 +191,15 @@ mod tests {
assert!(ChoppinessIndex::new(2).is_ok());
}
/// Cover the const accessor `period` (73-75) and the Indicator-impl
/// `name` body (125-127). `warmup_period` is exercised elsewhere.
#[test]
fn accessors_and_metadata() {
let ci = ChoppinessIndex::new(14).unwrap();
assert_eq!(ci.period(), 14);
assert_eq!(ci.name(), "ChoppinessIndex");
}
#[test]
fn reset_clears_state() {
let candles: Vec<Candle> = (0..20).map(|i| c(11.0, 9.0, 10.0, i)).collect();
@@ -160,6 +160,15 @@ mod tests {
assert!(ForceIndex::new(0).is_err());
}
/// Cover the const accessor `period` (58-60) and the Indicator-impl
/// `name` body (93-95). `warmup_period` is exercised elsewhere.
#[test]
fn accessors_and_metadata() {
let fi = ForceIndex::new(13).unwrap();
assert_eq!(fi.period(), 13);
assert_eq!(fi.name(), "ForceIndex");
}
#[test]
fn reset_clears_state() {
let candles: Vec<Candle> = (0..30).map(|i| c(10.0 + i as f64, 50.0, i)).collect();