SplitArray { public void splitSorting(int[] array) { if (array == null) { throw new IllegalArgumentException("Array passed as parameter can't be null."); } boolean flag = true; while (flag) { flag = false; for (int j = 0; j < array.length - 1; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1); flag = true; } } } }  void splitSorting(int[] array); void splitSwappingIterative(int[] array); void splitSwappingRecursive(int[] array);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullArraysSorting() { splitArray.splitSorting(null); }
@Test public void shouldSupportEmptyArraysSorting() { int[] array = new int[0]; splitArray.splitSorting(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldWorkWithAnArrayFullOfPositiveNumbersSorting() { int[] array = { 1, 2, 1, 3, 4, 6 }; splitArray.splitSorting(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldWorkWithAnArrayFullOfNegativeNumbersSorting() { int[] array = { 1, 2, 1, 3, 4, 6 }; splitArray.splitSorting(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldMoveNegativeElementsToTheLeftSorting() { int[] array = { 1, 2, -1, -3, 4, -6 }; splitArray.splitSorting(array); assertNegativeElementsAreBeforePositiveOnes(array); }
@Test public void shouldMoveNegativeElementsToTheLeftWithWithMoreNegativeElementsSorting() { int[] array = { 1, -2, -1, -3, 4, -6 }; splitArray.splitSorting(array); assertNegativeElementsAreBeforePositiveOnes(array); }