Skip to content

Commit 25d2d04

Browse files
committed
reserve: Add test with inverted axis
Testing when the allocation to first element offset is nonzero.
1 parent 8e030d1 commit 25d2d04

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/reserve.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@ fn reserve_2d_with_data()
5050
assert_eq!(a, array![[1, 2], [3, 4], [5, 6]]);
5151
assert!(a.into_raw_vec().capacity() >= 3 * 100);
5252
}
53+
54+
#[test]
55+
fn reserve_2d_inverted_with_data()
56+
{
57+
let mut a = array![[1, 2], [3, 4], [5, 6]];
58+
a.invert_axis(Axis(1));
59+
assert_eq!(a, array![[2, 1], [4, 3], [6, 5]]);
60+
a.reserve(Axis(1), 100).unwrap();
61+
assert_eq!(a, array![[2, 1], [4, 3], [6, 5]]);
62+
let (raw_vec, offset) = a.into_raw_vec_and_offset();
63+
assert!(raw_vec.capacity() >= 3 * 100);
64+
assert_eq!(offset, Some(1));
65+
}

0 commit comments

Comments
 (0)