Skip to content

Commit a0130ad

Browse files
committed
Add tests for zero handling in AxisChunksIter/Mut
1 parent d0c4c55 commit a0130ad

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/iterators.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,19 @@ fn axis_chunks_iter_zero_stride() {
574574
}
575575
}
576576

577+
#[should_panic]
578+
#[test]
579+
fn axis_chunks_iter_zero_chunk_size() {
580+
let a = Array::from_iter(0..5);
581+
a.axis_chunks_iter(Axis(0), 0);
582+
}
583+
584+
#[test]
585+
fn axis_chunks_iter_zero_axis_len() {
586+
let a = Array::from_iter(0..0);
587+
assert!(a.axis_chunks_iter(Axis(0), 5).next().is_none());
588+
}
589+
577590
#[test]
578591
fn axis_chunks_iter_mut() {
579592
let a = ArcArray::from_iter(0..24);
@@ -585,6 +598,19 @@ fn axis_chunks_iter_mut() {
585598
assert_eq!(col0, arr3(&[[[42, 1], [2, 3]], [[12, 13], [14, 15]]]));
586599
}
587600

601+
#[should_panic]
602+
#[test]
603+
fn axis_chunks_iter_mut_zero_chunk_size() {
604+
let mut a = Array::from_iter(0..5);
605+
a.axis_chunks_iter_mut(Axis(0), 0);
606+
}
607+
608+
#[test]
609+
fn axis_chunks_iter_mut_zero_axis_len() {
610+
let mut a = Array::from_iter(0..0);
611+
assert!(a.axis_chunks_iter_mut(Axis(0), 5).next().is_none());
612+
}
613+
588614
#[test]
589615
fn outer_iter_size_hint() {
590616
// Check that the size hint is correctly computed

0 commit comments

Comments
 (0)