diff --git a/src/test/java/net/imglib2/img/array/ArrayImgsTest.java b/src/test/java/net/imglib2/img/array/ArrayImgsTest.java index b87bd00b79..99aeafffbf 100644 --- a/src/test/java/net/imglib2/img/array/ArrayImgsTest.java +++ b/src/test/java/net/imglib2/img/array/ArrayImgsTest.java @@ -479,6 +479,10 @@ public static < T extends NativeType< T > & IntegerType< T > > void testRange( f final ArrayCursor< T > r = ref.cursor(); for ( int s = start; s < stop; ++s ) { + if ( !c.hasNext() || !r.hasNext() ) + { + Assert.fail( "Invalid iterators for test range" ); + } Assert.assertEquals( c.next().getInteger(), s ); Assert.assertEquals( r.next().getInteger(), s ); } diff --git a/src/test/java/net/imglib2/img/cell/CopyTest.java b/src/test/java/net/imglib2/img/cell/CopyTest.java index ff5509c686..63d769f33a 100644 --- a/src/test/java/net/imglib2/img/cell/CopyTest.java +++ b/src/test/java/net/imglib2/img/cell/CopyTest.java @@ -36,6 +36,7 @@ import static org.junit.Assert.assertArrayEquals; +import java.util.NoSuchElementException; import java.util.Random; import org.junit.Before; @@ -130,6 +131,10 @@ public void copyWithIterationBoth( final Img< IntType > srcImg, final Img< IntTy final Cursor< IntType > dst = dstImg.cursor(); while ( src.hasNext() ) { + if ( !dst.hasNext() ) + { + throw new NoSuchElementException(" Cursor dst does not have next element" ); + } dst.next().set( src.next().get() ); } } diff --git a/src/test/java/net/imglib2/view/RandomAccessibleIntervalCursorTest.java b/src/test/java/net/imglib2/view/RandomAccessibleIntervalCursorTest.java index d4707cb2d4..3ffaaf6f75 100644 --- a/src/test/java/net/imglib2/view/RandomAccessibleIntervalCursorTest.java +++ b/src/test/java/net/imglib2/view/RandomAccessibleIntervalCursorTest.java @@ -37,6 +37,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import java.util.NoSuchElementException; import java.util.Random; import org.junit.Before; @@ -103,7 +104,14 @@ public void setUp() public void copy( final Cursor< IntType > src, final Cursor< IntType > dst ) { while ( src.hasNext() ) + { + if ( !dst.hasNext() ) + { + throw new NoSuchElementException( "Cursor dst does not have next element" ); + } + dst.next().set( src.next().get() ); + } } int[] getImgAsInts( final Img< IntType > img )