Kotlinlearncs.online LogoJava
Return to List

Test Writing: Quicksort Partition (First Value)

Created By: Geoffrey Challen
/ Version: 2020.6.0

Create a method fun partition(value: IntArray?) that returns the input array partitioned using the first array value as the pivot. All values smaller than the pivot should precede it in the array, and all values larger than or equal to the pivot should follow it. Your method should return the index of the pivot value. If the array is null or empty you should return -1.

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a public class named TestPartitioner with a single non-private class method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Kotlin's assert or check methods