Well, it depends on what you have.
In addition to the usual tests in which you manually enter the inputs and outputs for checking angular affairs and several other inputs (see JUnit or a similar structure of a really popular language), you can also write an ineffective but simple version of your algorithm (or, more precisely, everything that gives the same results, usually not quite the same algorithm) and a test against this version, either for all possible inputs, or if this is not possible using Fuzztester and some randomization.
One example of later testing would be testing a complex sorting algorithm (say heapsort) against SelectionSort. This also works well if you are optimizing the code and already have a tested and verified version (which in itself is a recursive problem).
In your particular case, you can simply compare your version with a simple binary search, which, as a rule, the standard library already has - creating random sized arrays with random input should not be a problem either.
source share