This is the code snippet I have to test. I am not able to figure out how to test the following method which takes an array as a parameter and returns nothing. Is there a function on JUnit which tests this.
default void print(int[] a) {
System.out.print("{");
if (a.length > 0) {
System.out.print(a[0]);
for (int i = 1; i < a.length; i++) {
System.out.print(", " + a[i]);
}
}
System.out.println("}");
}
If I put an Array in the expected field it tells me that an int[] output cannot be compared with a void function. This is what I have written.
@Test
void test() {
var arr = new Array();
assertArrayEquals(new int[]{1, 2, 3}, arr.print(new int[]{1, 2, 3}));
}