|
34 | 34 | import net.imagej.ops2.AbstractOpTest; |
35 | 35 | import net.imglib2.type.numeric.integer.IntType; |
36 | 36 | import org.junit.jupiter.api.Test; |
| 37 | +import org.scijava.ops.engine.math.MathOps; |
37 | 38 |
|
38 | 39 | /** |
39 | 40 | * Tests {@link BinaryRealTypeMath}. |
|
42 | 43 | */ |
43 | 44 | public class BinaryRealTypeMathTest extends AbstractOpTest { |
44 | 45 |
|
| 46 | + private static final IntType A = new IntType(25); |
| 47 | + private static final IntType B = new IntType(25); |
45 | 48 | @Test |
46 | 49 | public void testAddF() { |
47 | | - IntType a = new IntType(25); |
48 | | - IntType b = new IntType(45); |
49 | | - IntType c = ops.binary("math.add").input(a, b).outType(IntType.class).apply(); |
50 | | - assertEquals(c.get(), a.get() + b.get()); |
| 50 | + for (String opName : MathOps.ADD.split(", ")) { |
| 51 | + IntType c = ops.binary(opName).input(A, B).outType(IntType.class).apply(); |
| 52 | + assertEquals(A.get() + B.get(), c.get()); |
| 53 | + } |
51 | 54 | } |
52 | 55 |
|
53 | 56 | @Test |
54 | 57 | public void testAddC() { |
55 | | - IntType a = new IntType(25); |
56 | | - IntType b = new IntType(45); |
57 | | - IntType c = new IntType(); |
58 | | - ops.binary("math.add").input(a, b).output(c).compute(); |
59 | | - assertEquals(c.get(), a.get() + b.get()); |
| 58 | + for (String opName : MathOps.ADD.split(", ")) { |
| 59 | + IntType c = new IntType(); |
| 60 | + ops.binary(opName).input(A, B).output(c).compute(); |
| 61 | + assertEquals(A.get() + B.get(), c.get()); |
| 62 | + } |
60 | 63 | } |
61 | 64 |
|
62 | | -// FIXME: currently not working |
| 65 | + @Test |
| 66 | + public void testSubF() { |
| 67 | + for (String opName : MathOps.SUB.split(", ")) { |
| 68 | + IntType c = ops.binary(opName).input(A, B).outType(IntType.class).apply(); |
| 69 | + assertEquals(A.get() - B.get(), c.get()); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + public void testSubC() { |
| 75 | + for (String opName : MathOps.SUB.split(", ")) { |
| 76 | + IntType c = new IntType(); |
| 77 | + ops.binary(opName).input(A, B).output(c).compute(); |
| 78 | + assertEquals(A.get() - B.get(), c.get()); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void testDivF() { |
| 84 | + for (String opName : MathOps.DIV.split(", ")) { |
| 85 | + IntType c = ops.binary(opName).input(A, B).outType(IntType.class).apply(); |
| 86 | + assertEquals(A.get() / B.get(), c.get()); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + @Test |
| 91 | + public void testDivC() { |
| 92 | + for (String opName : MathOps.DIV.split(", ")) { |
| 93 | + IntType c = new IntType(); |
| 94 | + ops.binary(opName).input(A, B).output(c).compute(); |
| 95 | + assertEquals(A.get() / B.get(), c.get()); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + @Test |
| 100 | + public void testMulF() { |
| 101 | + for (String opName : MathOps.MUL.split(", ")) { |
| 102 | + IntType c = ops.binary(opName).input(A, B).outType(IntType.class).apply(); |
| 103 | + assertEquals(A.get() * B.get(), c.get()); |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + @Test |
| 108 | + public void testMulC() { |
| 109 | + for (String opName : MathOps.MUL.split(", ")) { |
| 110 | + IntType c = new IntType(); |
| 111 | + ops.binary(opName).input(A, B).output(c).compute(); |
| 112 | + assertEquals(A.get() * B.get(), c.get()); |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | +// FIXME: inplaces would be nice |
63 | 117 | // @Test |
64 | 118 | // public void testAddI() { |
65 | 119 | // IntType a = new IntType(25); |
|
0 commit comments