Skip to content

Commit 61cea3f

Browse files
committed
TEST: Add tests for appending empty arrays
1 parent ec75d18 commit 61cea3f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/append.rs

+19
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,22 @@ fn test_append_middle_axis() {
195195
a.try_append_array(Axis(1), Array::from_iter(12..24).into_shape((3, 2, 2)).unwrap().view()).unwrap();
196196
println!("{:?}", a);
197197
}
198+
199+
#[test]
200+
fn test_append_zero_size() {
201+
{
202+
let mut a = Array::<i32, _>::zeros((0, 0));
203+
a.try_append_array(Axis(0), aview2(&[[]])).unwrap();
204+
a.try_append_array(Axis(0), aview2(&[[]])).unwrap();
205+
assert_eq!(a.len(), 0);
206+
assert_eq!(a.shape(), &[2, 0]);
207+
}
208+
209+
{
210+
let mut a = Array::<i32, _>::zeros((0, 0));
211+
a.try_append_array(Axis(1), ArrayView::from(&[]).into_shape((0, 1)).unwrap()).unwrap();
212+
a.try_append_array(Axis(1), ArrayView::from(&[]).into_shape((0, 1)).unwrap()).unwrap();
213+
assert_eq!(a.len(), 0);
214+
assert_eq!(a.shape(), &[0, 2]);
215+
}
216+
}

0 commit comments

Comments
 (0)