Skip to content

Commit 0b1a42c

Browse files
committed
Eliminated unneeded AssertIterations class
Use ImgLib2Assert.assertImageEquals instead. It is simpler with better failure messages.
1 parent 8b8e76a commit 0b1a42c

5 files changed

Lines changed: 25 additions & 56 deletions

File tree

imagej/imagej-ops2/src/test/java/net/imagej/ops2/coloc/ShuffledViewTest.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@
2929

3030
package net.imagej.ops2.coloc;
3131

32-
import static org.junit.jupiter.api.Assertions.assertTrue;
33-
3432
import net.imglib2.img.array.ArrayImg;
3533
import net.imglib2.img.array.ArrayImgs;
3634
import net.imglib2.img.basictypeaccess.array.ByteArray;
35+
import net.imglib2.test.ImgLib2Assert;
3736
import net.imglib2.type.numeric.RealType;
3837
import net.imglib2.type.numeric.integer.UnsignedByteType;
39-
import net.imglib2.view.Views;
4038

4139
import org.junit.jupiter.api.Test;
42-
import org.scijava.testutil.AssertIterations;
4340

4441
public class ShuffledViewTest extends ColocalisationTest {
4542

@@ -74,7 +71,7 @@ public void testShuffleView() {
7471
1, 2, 29, 30, 25, 26, //
7572
7, 8, 35, 36, 31, 32 //
7673
}, 6, 6);
77-
assertTrue(AssertIterations.equal(expected, Views.iterable(shuffled)));
74+
ImgLib2Assert.assertImageEquals(expected, shuffled);
7875
}
7976

8077
/*
@@ -98,8 +95,7 @@ public void testSameSeed() {
9895
blockSize, seed);
9996
ShuffledView<UnsignedByteType> shuffled02 = new ShuffledView<>(inputImage,
10097
blockSize, seed);
101-
assertTrue(AssertIterations.equal(Views.iterable(shuffled01), Views.iterable(
102-
shuffled02)));
98+
ImgLib2Assert.assertImageEquals(shuffled01, shuffled02);
10399
}
104100

105101
/*
@@ -142,8 +138,8 @@ public <T extends RealType<T>, U extends RealType<U>> void testDiffSeeds() {
142138
3, 4, 13, 14, 1, 2, //
143139
9, 10, 19, 20, 7, 8 //
144140
}, 6, 6);
145-
assertTrue(AssertIterations.equal(expected1, Views.iterable(shuffled1)));
146-
assertTrue(AssertIterations.equal(expected2, Views.iterable(shuffled2)));
141+
ImgLib2Assert.assertImageEquals(expected1, shuffled1);
142+
ImgLib2Assert.assertImageEquals(expected2, shuffled2);
147143
}
148144

149145
/*
@@ -174,7 +170,7 @@ public void testNonSquareBlocks1() {
174170
29, 30, 9, 10, 25, 26, //
175171
35, 36, 15, 16, 31, 32 //
176172
}, 6, 6);
177-
assertTrue(AssertIterations.equal(expected, Views.iterable(shuffled)));
173+
ImgLib2Assert.assertImageEquals(expected, shuffled);
178174
}
179175

180176
/*
@@ -205,7 +201,7 @@ public void testNonSquareBlocks2() {
205201
4, 5, 6, 16, 17, 18, //
206202
10, 11, 12, 22, 23, 24 //
207203
}, 6, 6);
208-
assertTrue(AssertIterations.equal(expected, Views.iterable(shuffled)));
204+
ImgLib2Assert.assertImageEquals(expected, shuffled);
209205
}
210206

211207
/*
@@ -236,6 +232,6 @@ public void testAllShuffle() {
236232
11, 25, 4, 24, 26, 6, //
237233
23, 10, 13, 15, 22, 16 //
238234
}, 6, 6);
239-
assertTrue(AssertIterations.equal(expected, Views.iterable(shuffled)));
235+
ImgLib2Assert.assertImageEquals(expected, shuffled);
240236
}
241237
}

imagej/imagej-ops2/src/test/java/net/imagej/ops2/filter/tubeness/TubenessTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,18 @@
2929

3030
package net.imagej.ops2.filter.tubeness;
3131

32-
import static org.junit.jupiter.api.Assertions.assertTrue;
33-
3432
import java.util.concurrent.ExecutorService;
3533

36-
import org.junit.jupiter.api.Test;
37-
import org.scijava.types.Nil;
38-
import org.scijava.testutil.AssertIterations;
39-
import org.scijava.thread.ThreadService;
40-
4134
import net.imagej.ops2.AbstractOpTest;
4235
import net.imglib2.img.Img;
36+
import net.imglib2.test.ImgLib2Assert;
4337
import net.imglib2.type.numeric.integer.UnsignedByteType;
4438
import net.imglib2.type.numeric.real.DoubleType;
4539

40+
import org.junit.jupiter.api.Test;
41+
import org.scijava.thread.ThreadService;
42+
import org.scijava.types.Nil;
43+
4644
/**
4745
* Tests {@link DefaultTubeness}.
4846
*
@@ -63,8 +61,7 @@ public void testTubeness() {
6361
.outType(new Nil<Img<DoubleType>>() {}).apply();
6462
ops.op("filter.tubeness").input(input, es, sigma).output(actual).compute();
6563

66-
assertTrue(AssertIterations.equal(expected, actual));
67-
64+
ImgLib2Assert.assertImageEquals(expected, actual);
6865
}
6966

7067
}

imagej/imagej-ops2/src/test/java/net/imagej/ops2/morphology/blackTopHat/BlackTopHatTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,23 @@
2929

3030
package net.imagej.ops2.morphology.blackTopHat;
3131

32-
import static org.junit.jupiter.api.Assertions.assertTrue;
33-
3432
import java.util.ArrayList;
3533
import java.util.Arrays;
3634
import java.util.List;
3735

3836
import net.imagej.ops2.AbstractOpTest;
3937
import net.imagej.testutil.TestImgGeneration;
40-
import net.imglib2.IterableInterval;
4138
import net.imglib2.algorithm.morphology.BlackTopHat;
4239
import net.imglib2.algorithm.neighborhood.DiamondShape;
4340
import net.imglib2.algorithm.neighborhood.HorizontalLineShape;
4441
import net.imglib2.algorithm.neighborhood.RectangleShape;
4542
import net.imglib2.algorithm.neighborhood.Shape;
4643
import net.imglib2.img.Img;
44+
import net.imglib2.test.ImgLib2Assert;
4745
import net.imglib2.type.numeric.integer.ByteType;
4846

4947
import org.junit.jupiter.api.BeforeEach;
5048
import org.junit.jupiter.api.Test;
51-
import org.scijava.testutil.AssertIterations;
5249
import org.scijava.types.Nil;
5350

5451
/**
@@ -72,7 +69,7 @@ public void testSingleBlackTopHat() {
7269
final Img<ByteType> out1 = ops.op("morphology.BlackTopHat").input(in, shapes, 1)
7370
.outType(new Nil<Img<ByteType>>() {}).apply();
7471
final Img<ByteType> out2 = BlackTopHat.blackTopHat(in, shape, 1);
75-
assertTrue(AssertIterations.equal(out2, out1));
72+
ImgLib2Assert.assertImageEquals(out2, out1);
7673
}
7774

7875
@Test
@@ -82,9 +79,9 @@ public void testListBlackTopHat() {
8279
shapes.add(new DiamondShape(1));
8380
shapes.add(new RectangleShape(1, false));
8481
shapes.add(new HorizontalLineShape(2, 1, false));
85-
final IterableInterval<ByteType> out1 = ops.op("morphology.BlackTopHat").input(in, shapes, 1)
86-
.outType(new Nil<IterableInterval<ByteType>>() {}).apply();
82+
final Img<ByteType> out1 = ops.op("morphology.BlackTopHat").input(in, shapes, 1)
83+
.outType(new Nil<Img<ByteType>>() {}).apply();
8784
final Img<ByteType> out2 = BlackTopHat.blackTopHat(in, shapes, 1);
88-
assertTrue(AssertIterations.equal(out2, out1));
85+
ImgLib2Assert.assertImageEquals(out2, out1);
8986
}
9087
}

imagej/imagej-ops2/src/test/java/net/imagej/ops2/morphology/thin/ThinningTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@
2929

3030
package net.imagej.ops2.morphology.thin;
3131

32-
import static org.junit.jupiter.api.Assertions.assertTrue;
33-
3432
import net.imagej.ops2.AbstractOpTest;
3533
import net.imagej.ops2.features.AbstractFeatureTest;
3634
import net.imglib2.img.Img;
35+
import net.imglib2.test.ImgLib2Assert;
3736
import net.imglib2.type.logic.BitType;
3837
import net.imglib2.type.numeric.real.FloatType;
3938

4039
import org.junit.jupiter.api.BeforeEach;
4140
import org.junit.jupiter.api.Test;
42-
import org.scijava.testutil.AssertIterations;
4341
import org.scijava.types.Nil;
4442

4543
/**
46-
* Tests for {@link net.imagej.ops2.Ops.Morphology} thinning ops.
44+
* Tests for morphology thinning ops.
4745
*
4846
* @author Kyle Harrington
4947
*/
@@ -65,28 +63,28 @@ public void initialize() {
6563
public void testThinGuoHall() {
6664
final Img<BitType> out = ops.op("morphology.thinGuoHall").input(in).outType(new Nil<Img<BitType>>() {}).apply();
6765
ops.op("convert.bit").input(openFloatImg(AbstractThin.class, "result_guoHall.tif")).output(target).compute();
68-
assertTrue(AssertIterations.equal(target, out));
66+
ImgLib2Assert.assertImageEquals(target, out);
6967
}
7068

7169
@Test
7270
public void testThinHilditch() {
7371
final Img<BitType> out = ops.op("morphology.thinHilditch").input(in).outType(new Nil<Img<BitType>>() {}).apply();
7472
ops.op("convert.bit").input(openFloatImg(AbstractThin.class, "result_hilditch.tif")).output(target).compute();
75-
assertTrue(AssertIterations.equal(target, out));
73+
ImgLib2Assert.assertImageEquals(target, out);
7674
}
7775

7876
@Test
7977
public void testMorphological() {
8078
final Img<BitType> out = ops.op("morphology.thinMorphological").input(in).outType(new Nil<Img<BitType>>() {})
8179
.apply();
8280
ops.op("convert.bit").input(openFloatImg(AbstractThin.class, "result_morphological.tif")).output(target).compute();
83-
assertTrue(AssertIterations.equal(target, out));
81+
ImgLib2Assert.assertImageEquals(target, out);
8482
}
8583

8684
@Test
8785
public void testZhangSuen() {
8886
final Img<BitType> out = ops.op("morphology.thinZhangSuen").input(in).outType(new Nil<Img<BitType>>() {}).apply();
8987
ops.op("convert.bit").input(openFloatImg(AbstractThin.class, "result_zhangSuen.tif")).output(target).compute();
90-
assertTrue(AssertIterations.equal(target, out));
88+
ImgLib2Assert.assertImageEquals(target, out);
9189
}
9290
}

scijava/scijava-testutil/src/main/java/org/scijava/testutil/AssertIterations.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)