Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
m5l14i11 committed Jul 1, 2023
1 parent 2b950cf commit 13ed1b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ta_lib/volatility/src/atr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ mod tests {
let low = vec![1.0, 2.0, 3.0];
let close = vec![1.5, 3.0, 4.5];
let period = 3;
let epsilon = 0.001;
let smothing = Some("SMMA");
let expected = vec![None, None, Some(1.5555)];

let result = atr(&high, &low, &close, period, smothing);

assert_eq!(result, expected);
for i in 0..high.len() {
match (result[i], expected[i]) {
(Some(a), Some(b)) => {
assert!((a - b).abs() < epsilon, "at position {}: {} != {}", i, a, b)
}
(None, None) => {}
_ => panic!("at position {}: {:?} != {:?}", i, result[i], expected[i]),
}
}
}
}

0 comments on commit 13ed1b9

Please sign in to comment.