test(resample): cover RolledBar::absorb low-update branch
Codecov flagged a single uncovered line in crates/wickra-data/src/resample.rs: line 46, the `self.low = c.low;` assignment inside RolledBar::absorb. None of the existing resampler tests fed a follow-up candle with a strictly lower low than the first candle in the bucket, so the `c.low < self.low` branch never fired. Coverage stayed at 122/123. Add a small dedicated test that pushes a 10.0-low candle into bucket 0, then a 8.0-low candle into the same bucket, and asserts the rolled bar's low reflects the dip. Resample file is now at 123/123 lines, no behavioural change.
This commit is contained in:
@@ -192,6 +192,20 @@ mod tests {
|
||||
assert_eq!(bar.low, 9.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn absorb_lowers_low_on_dipping_candle() {
|
||||
// The first candle in the bucket sets low = 10.0; the second dips to
|
||||
// 8.0 and must overwrite. Exercises the `c.low < self.low` branch in
|
||||
// RolledBar::absorb that the other resampler tests never trigger
|
||||
// because their follow-up candles always have a higher low.
|
||||
let mut r = Resampler::new(Timeframe::new(5).unwrap());
|
||||
r.push(c(0, 10.0, 11.0, 10.0, 10.5, 1.0)).unwrap();
|
||||
r.push(c(1, 10.5, 11.5, 8.0, 9.0, 1.0)).unwrap();
|
||||
let bar = r.flush().unwrap().unwrap();
|
||||
assert_eq!(bar.low, 8.0);
|
||||
assert_eq!(bar.high, 11.5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flushes_a_non_finite_volume_as_an_error() {
|
||||
let mut r = Resampler::new(Timeframe::new(5).unwrap());
|
||||
|
||||
Reference in New Issue
Block a user