#[cfg(test)] mod unit_tests { use peak_finder::data::{slope2d::Slope2D, errors::DivisionByZero, find_inflection_point, is_more, is_less}; #[test] fn test_slope() { let test_point_one = (1.0_f32, 1.0_f32); let test_point_two = (2.0_f32, 2.0_f32); assert_eq!(Slope2D::new(test_point_one, test_point_two).unwrap().is, 1.0_f32); assert!(Slope2D::new(test_point_one, test_point_one).is_err()); assert_eq!(Slope2D::new(test_point_one, test_point_one).unwrap_err(), DivisionByZero); } #[test] fn test_inflection_point() { assert_eq!(find_inflection_point(&Vec::from([2,3,4,5,3,1,2]), is_less).unwrap(), (3, 5)); assert_eq!(find_inflection_point(&Vec::from([5,4,3,2,1,2,3]), is_more).unwrap(), (4, 1)); } }