Skip to content

Commit

Permalink
reserve: Add test with inverted axis
Browse files Browse the repository at this point in the history
Testing when the allocation to first element offset is nonzero.
  • Loading branch information
bluss committed Apr 6, 2024
1 parent 8e030d1 commit 25d2d04
Showing 1 changed file with 13 additions and 0 deletions.
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));
}

0 comments on commit 25d2d04

Please sign in to comment.