SplitArray { public void splitSwappingRecursive(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } if (array.length == 0) { return; } splitSwappingRecursiveInner(array, 0, array.length - 1); }  void splitSorting(int[] array); void splitSwappingIterative(int[] array); void splitSwappingRecursive(int[] array);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullArraysWithTwoPointersRecursive() { splitArray.splitSwappingRecursive(null); }
@Test public void shouldSupportEmptyArraysWithTwoPointersRecursive() { int[] array = new int[0]; splitArray.splitSwappingRecursive(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldWorkWithAnArrayFullOfPositiveNumbersWithTwoPointersRecursive() { int[] array = { 1, 2, 1, 3, 4, 6 }; splitArray.splitSwappingRecursive(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldWorkWithAnArrayFullOfNegativeNumbersWithTwoPointersRecursive() { int[] array = { 1, 2, 1, 3, 4, 6 }; splitArray.splitSwappingRecursive(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldMoveNegativeElementsToTheLeftWithTwoPointersRecursive() { int[] array = { 1, 2, -1, -3, 4, -6 }; splitArray.splitSwappingRecursive(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldMoveNegativeElementsToTheLeftWithWithMoreNegativeElementsTwoPointersRecursive() { int[] array = { 1, -2, -1, -3, 4, -6 }; splitArray.splitSwappingRecursive(array); assertNegativeElementsAreBeforePositiveOnes(array); }