|
33 | 33 | import org.junit.jupiter.api.BeforeAll; |
34 | 34 | import org.junit.jupiter.api.Test; |
35 | 35 | import org.scijava.function.Computers; |
| 36 | +import org.scijava.function.Container; |
36 | 37 | import org.scijava.function.Functions; |
37 | 38 | import org.scijava.ops.engine.AbstractTestEnvironment; |
38 | 39 | import org.scijava.ops.spi.OpCollection; |
@@ -163,4 +164,48 @@ public void testMethodWithoutNullables() { |
163 | 164 | Assertions.assertEquals(expected, out); |
164 | 165 | } |
165 | 166 |
|
| 167 | + @OpMethod(names = "test.nullableOr", type = Computers.Arity3_3.class) |
| 168 | + public static void nullablePermutedComputer( // |
| 169 | + int[] in1, // |
| 170 | + @Nullable int[] in2, // |
| 171 | + @Container int[] out, // |
| 172 | + @Nullable int[] in3 // |
| 173 | + ) { |
| 174 | + if (in2 == null) in2 = new int[in1.length]; |
| 175 | + if (in3 == null) in3 = new int[in1.length]; |
| 176 | + for (int i = 0; i < out.length; i++) { |
| 177 | + out[i] = in1[i] | in2[i] | in3[i]; |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + @Test |
| 182 | + public void testPermutedMethodWithTwoNullables() { |
| 183 | + int[] out = new int[1]; |
| 184 | + ops.op("test.nullableOr").arity3().input( // |
| 185 | + new int[] { 1 }, // |
| 186 | + new int[] { 2 }, // |
| 187 | + new int[] { 4 } // |
| 188 | + ).output(out).compute(); |
| 189 | + Assertions.assertEquals(7, out[0]); |
| 190 | + } |
| 191 | + |
| 192 | + @Test |
| 193 | + public void testPermutedMethodWithOneNullable() { |
| 194 | + int[] out = new int[1]; |
| 195 | + ops.op("test.nullableOr").arity2().input( // |
| 196 | + new int[] { 1 }, // |
| 197 | + new int[] { 2 } // |
| 198 | + ).output(out).compute(); |
| 199 | + Assertions.assertEquals(3, out[0]); |
| 200 | + } |
| 201 | + |
| 202 | + @Test |
| 203 | + public void testPermutedMethodWithoutNullables() { |
| 204 | + int[] out = new int[1]; |
| 205 | + ops.op("test.nullableOr").arity1().input( // |
| 206 | + new int[] { 1 } // |
| 207 | + ).output(out).compute(); |
| 208 | + Assertions.assertEquals(1, out[0]); |
| 209 | + } |
| 210 | + |
166 | 211 | } |
0 commit comments