Skip to content

Commit 5da1265

Browse files
committed
Test non-standard computer reduction
1 parent a76e4b8 commit 5da1265

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

scijava-ops-engine/src/test/java/org/scijava/ops/engine/reduce/NullableArgumentsTest.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.junit.jupiter.api.BeforeAll;
3434
import org.junit.jupiter.api.Test;
3535
import org.scijava.function.Computers;
36+
import org.scijava.function.Container;
3637
import org.scijava.function.Functions;
3738
import org.scijava.ops.engine.AbstractTestEnvironment;
3839
import org.scijava.ops.spi.OpCollection;
@@ -163,4 +164,48 @@ public void testMethodWithoutNullables() {
163164
Assertions.assertEquals(expected, out);
164165
}
165166

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+
166211
}

0 commit comments

Comments
 (0)