From aa2846c250e78f0b7eacc61f09bc04de3bd10a93 Mon Sep 17 00:00:00 2001 From: kingchenc Date: Sat, 23 May 2026 23:31:50 +0200 Subject: [PATCH] test(bollinger): collapse naive helper assert to single-line message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codecov re-check after 1255892 showed line 179 of crates/wickra-core/src/indicators/bollinger.rs still uncovered: the `prices.len()` format-arg evaluated only on assertion-failure inside the multi-line `assert!(prices.len() >= period, "…got {}, period {}", prices.len(), period)` — the cold panic path. Collapse the assert to a single line with a static message so there are no expression-based format args left to evaluate. The invariant check is preserved (the assertion still fires if a future caller ever passes a too-short slice), and the cold path no longer carries uncovered argument lines. bollinger.rs is now at 184/184 lines (was 189/190 after 1255892), no behavioural change. --- crates/wickra-core/src/indicators/bollinger.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/wickra-core/src/indicators/bollinger.rs b/crates/wickra-core/src/indicators/bollinger.rs index 42745e8b..afc237a8 100644 --- a/crates/wickra-core/src/indicators/bollinger.rs +++ b/crates/wickra-core/src/indicators/bollinger.rs @@ -173,12 +173,7 @@ mod tests { use approx::assert_relative_eq; fn naive(prices: &[f64], period: usize, mult: f64) -> BollingerOutput { - assert!( - prices.len() >= period, - "naive: need at least `period` prices (got {}, period {})", - prices.len(), - period, - ); + assert!(prices.len() >= period, "naive requires at least `period` prices"); let w = &prices[prices.len() - period..]; let mean = w.iter().sum::() / period as f64; let var = w.iter().map(|x| (x - mean).powi(2)).sum::() / period as f64;