From ce9ff1d9c82d76d66976469c32e0a6375dbe7ace Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 8 Aug 2024 09:38:14 +0200 Subject: [PATCH] test imglib2 push and pull --- src/test/java/TestImgLibPushAndPull.java | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/TestImgLibPushAndPull.java diff --git a/src/test/java/TestImgLibPushAndPull.java b/src/test/java/TestImgLibPushAndPull.java new file mode 100644 index 0000000..206e558 --- /dev/null +++ b/src/test/java/TestImgLibPushAndPull.java @@ -0,0 +1,37 @@ +import org.junit.jupiter.api.Test; + +import net.imglib2.Cursor; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.numeric.integer.IntType; +import net.clesperanto.core.ArrayJ; +import net.clesperanto.core.DeviceJ; +import net.clesperanto.imglib2.ImgLib2Converters; + +import static org.junit.jupiter.api.Assertions.*; + + +public class TestImgLibPushAndPull { + + @Test + public void testImgLibPushAndPull() { + int[] flatVals = new int[18]; + for (int i = 0; i < flatVals.length; i ++) + flatVals[i] = i; + RandomAccessibleInterval inputImg = ArrayImgs.ints(flatVals, new long[] {3, 3, 2}); + + + DeviceJ device = DeviceJ.getDefaultDevice(); + ArrayJ in = ImgLib2Converters.copyImgLib2ToArrayJ(inputImg, device, "buffer"); + RandomAccessibleInterval outputImg = ImgLib2Converters.copyArrayJToImgLib2(in); + + Cursor inCursor = inputImg.cursor(); + Cursor outCursor = outputImg.cursor(); + + while (inCursor.hasNext()) { + assertEquals(inCursor.get().get(), outCursor.get().get()); + inCursor.next(); + outCursor.next(); + } + } +} \ No newline at end of file