My test asserts true, even though I have different values in the Series.
In the below test index 0 (100.94947) is wrong but it passes
pub fn convert_tb_to_tib(s: Series) -> Series {
let result = s.cast(&DataType::Float64).unwrap() * 0.90949470177293;
result
}
fn test_convert_tb_to_tib() {
let test_s = Series::new("", &[100, 200, 300, 400]);
let transformed_s = convert_tb_to_tib(test_s);
let expected_s = Series::new("", &[100.94947, 181.89894, 272.848411, 373.797881]);
transformed_s.series_equal(&expected_s);
}
test wrangle::tests::test_convert_tb_to_tib ... ok
I can evidence this by using the assert_eq! macro instead:
fn test_convert_tb_to_tib() {
let test_s = Series::new("", &[100, 200, 300, 400]);
let transformed_s = convert_tb_to_tib(test_s);
let expected_s = Series::new("", &[100.94947, 181.89894, 272.848411, 373.797881]);
assert_eq!(transformed_s, expected_s);
}
thread 'wrangle::tests::test_convert_tb_to_tib' panicked at 'assertion failed: `(left == right)`
left: `shape: (4,)
Series: '' [f64]
[
90.94947
181.89894
272.848411
363.797881
]`,
right: `shape: (4,)
Series: '' [f64]
[
100.94947
181.89894
272.848411
373.797881
]`', src/wrangle.rs:108:9
Why does this test pass when using the series_eq method?
series_equal()
doesn't assert anything, it only compares and returns a boolean.
You need to assert!()
its result:
assert!(transformed_s.series_equal(&expected_s));
But I recommend you to just use assert_eq!()
.