diff --git a/tests/reserve.rs b/tests/reserve.rs index c220c1715..108620014 100644 --- a/tests/reserve.rs +++ b/tests/reserve.rs @@ -1,12 +1,17 @@ use ndarray::prelude::*; +fn into_raw_vec_capacity(a: Array) -> usize +{ + a.into_raw_vec_and_offset().0.capacity() +} + #[test] fn reserve_1d() { let mut a = Array1::::zeros((4,)); a.reserve(Axis(0), 1000).unwrap(); assert_eq!(a.shape(), &[4]); - assert!(a.into_raw_vec().capacity() >= 1004); + assert!(into_raw_vec_capacity(a) >= 1004); } #[test] @@ -15,7 +20,7 @@ fn reserve_3d() let mut a = Array3::::zeros((0, 4, 8)); a.reserve(Axis(0), 10).unwrap(); assert_eq!(a.shape(), &[0, 4, 8]); - assert!(a.into_raw_vec().capacity() >= 4 * 8 * 10); + assert!(into_raw_vec_capacity(a) >= 4 * 8 * 10); } #[test] @@ -30,7 +35,7 @@ fn reserve_3d_axis1() { let mut a = Array3::::zeros((2, 4, 8)); a.reserve(Axis(1), 10).unwrap(); - assert!(a.into_raw_vec().capacity() >= 2 * 8 * 10); + assert!(into_raw_vec_capacity(a) >= 2 * 8 * 10); } #[test] @@ -39,7 +44,7 @@ fn reserve_3d_repeat() let mut a = Array3::::zeros((2, 4, 8)); a.reserve(Axis(1), 10).unwrap(); a.reserve(Axis(2), 30).unwrap(); - assert!(a.into_raw_vec().capacity() >= 2 * 4 * 30); + assert!(into_raw_vec_capacity(a) >= 2 * 4 * 30); } #[test] @@ -48,7 +53,7 @@ fn reserve_2d_with_data() let mut a = array![[1, 2], [3, 4], [5, 6]]; a.reserve(Axis(1), 100).unwrap(); assert_eq!(a, array![[1, 2], [3, 4], [5, 6]]); - assert!(a.into_raw_vec().capacity() >= 3 * 100); + assert!(into_raw_vec_capacity(a) >= 3 * 100); } #[test]