From 8f6ffe5a6260490b104a7d1e523aa167387efc2d Mon Sep 17 00:00:00 2001 From: kingchenc Date: Sun, 24 May 2026 00:47:56 +0200 Subject: [PATCH] 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). --- .../wickra-core/src/indicators/chaikin_volatility.rs | 9 +++++++++ .../wickra-core/src/indicators/chande_kroll_stop.rs | 12 ++++++++++++ crates/wickra-core/src/indicators/chandelier_exit.rs | 11 +++++++++++ .../wickra-core/src/indicators/choppiness_index.rs | 9 +++++++++ crates/wickra-core/src/indicators/force_index.rs | 9 +++++++++ 5 files changed, 50 insertions(+) diff --git a/crates/wickra-core/src/indicators/chaikin_volatility.rs b/crates/wickra-core/src/indicators/chaikin_volatility.rs index 0a0cc1b8..0ca8b84d 100644 --- a/crates/wickra-core/src/indicators/chaikin_volatility.rs +++ b/crates/wickra-core/src/indicators/chaikin_volatility.rs @@ -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 = (0..40) diff --git a/crates/wickra-core/src/indicators/chande_kroll_stop.rs b/crates/wickra-core/src/indicators/chande_kroll_stop.rs index e18739f9..813885a4 100644 --- a/crates/wickra-core/src/indicators/chande_kroll_stop.rs +++ b/crates/wickra-core/src/indicators/chande_kroll_stop.rs @@ -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 = (0..40) diff --git a/crates/wickra-core/src/indicators/chandelier_exit.rs b/crates/wickra-core/src/indicators/chandelier_exit.rs index a734ef5c..c79841cd 100644 --- a/crates/wickra-core/src/indicators/chandelier_exit.rs +++ b/crates/wickra-core/src/indicators/chandelier_exit.rs @@ -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 = (0..40) diff --git a/crates/wickra-core/src/indicators/choppiness_index.rs b/crates/wickra-core/src/indicators/choppiness_index.rs index 1b3aa91a..e5f9c0b5 100644 --- a/crates/wickra-core/src/indicators/choppiness_index.rs +++ b/crates/wickra-core/src/indicators/choppiness_index.rs @@ -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 = (0..20).map(|i| c(11.0, 9.0, 10.0, i)).collect(); diff --git a/crates/wickra-core/src/indicators/force_index.rs b/crates/wickra-core/src/indicators/force_index.rs index 55b5b5ec..d47874e6 100644 --- a/crates/wickra-core/src/indicators/force_index.rs +++ b/crates/wickra-core/src/indicators/force_index.rs @@ -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 = (0..30).map(|i| c(10.0 + i as f64, 50.0, i)).collect();