Skip to content
Prev Previous commit
Next Next commit
reserve: Add test with inverted axis
Testing when the allocation to first element offset is nonzero.
  • Loading branch information
bluss committed Apr 6, 2024
commit 25d2d04a3e7572251b822fdfa90979a4a7d6e2b6
13 changes: 13 additions & 0 deletions tests/reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ fn reserve_2d_with_data()
assert_eq!(a, array![[1, 2], [3, 4], [5, 6]]);
assert!(a.into_raw_vec().capacity() >= 3 * 100);
}

#[test]
fn reserve_2d_inverted_with_data()
{
let mut a = array![[1, 2], [3, 4], [5, 6]];
a.invert_axis(Axis(1));
assert_eq!(a, array![[2, 1], [4, 3], [6, 5]]);
a.reserve(Axis(1), 100).unwrap();
assert_eq!(a, array![[2, 1], [4, 3], [6, 5]]);
let (raw_vec, offset) = a.into_raw_vec_and_offset();
assert!(raw_vec.capacity() >= 3 * 100);
assert_eq!(offset, Some(1));
}