A3: close core test-coverage gaps
Adds the reset tests the audit named as missing (aroon, awesome oscillator, donchian, keltner, williams_r, and both VWAP variants), non-finite-input tests for every scalar indicator that guards is_finite (WMA, RSI, MACD, Bollinger, KAMA), and naive-reference proptests for EMA, RSI and ATR. 189 core tests pass.
This commit is contained in:
@@ -240,4 +240,17 @@ mod tests {
|
||||
bb.reset();
|
||||
assert!(!bb.is_ready());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignores_non_finite_input() {
|
||||
let mut bb = BollingerBands::new(5, 2.0).unwrap();
|
||||
let ready = bb.batch(&[1.0, 2.0, 3.0, 4.0, 5.0]);
|
||||
let last = ready.last().unwrap().unwrap();
|
||||
// Non-finite inputs return the current bands without mutating the window.
|
||||
assert_eq!(bb.update(f64::NAN).unwrap(), last);
|
||||
assert_eq!(bb.update(f64::INFINITY).unwrap(), last);
|
||||
// The window still holds 1..=5, so a real input slides it to 2..=6.
|
||||
let after = bb.update(6.0).unwrap();
|
||||
assert_relative_eq!(after.middle, (2.0 + 3.0 + 4.0 + 5.0 + 6.0) / 5.0, epsilon = 1e-12);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user