AddOne { public static int[] addOne(int[] array) { int carrier = 1; int[] result = new int[array.length]; for (int i = array.length - 1; i >= 0; i--) { result[i] = array[i] + carrier; if (result[i] > 9) { result[i] -= 10; carrier = 1; } else { carrier = 0; } } if (carrier == 1) { result = new int[array.length + 1]; result[0] = 1; } return result; }  static int[] addOne(int[] array);  }
@Test(dataProvider = "addOneDP") public void test(int[] input, int[] expected) { assertEquals(AddOne.addOne(input), expected); }