Question: The code should pass the junit test public static int[] task4(int[] seq) { int[] result = null; int size=0; int prevIndex = -1; for(int i=0;i
The code should pass the junit test public static int[] task4(int[] seq) { int[] result = null; int size=0; int prevIndex = -1; for(int i=0;i JUNIT TEST @Test public void test_task4_1() { int[] seq = {3, 1, 1, 1, 2, 2, 2, 2}; int[] expected = {1, 3, 3, 1, 4, 2}; assertArrayEquals(expected, Utilities.task4(seq)); } @Test public void test_task4_2() { int[] seq = {1, 1, 1, 2, 2, 2, 2}; int[] expected = {3, 1, 4, 2}; assertArrayEquals(expected, Utilities.task4(seq)); } @Test public void test_task4_3() { int[] seq = {2, 2, 2, 2, 1, 1, 1}; int[] expected = {4, 2, 3, 1}; assertArrayEquals(expected, Utilities.task4(seq)); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
