Sorting routines are widely used in almost all software project. I would like to share few of the most common test cases that can be used to break a sorting algorithm.

Functional test cases:

1. Input array is empty

2. Input array contains only one element

3. Input array is already sorted in order

4. Input array is sorted in revered order

5. Input array contains both +ve and -ve values

6. Input array contains repeated element

7. Input array contains an element which is the maximum allowed value in allowed range

8. Input array contains an element which greater than the maximum allowed value in allowed range

9. Input array contains an element which is the minimum allowed value in allowed range

10. Input array contains an element which less than the minimum allowed value in allowed range

11. Input array contains both integer and floating point numbers (possible to test if we use scripting languages like ruby)

12. Input array contains floating point numbers

Accuracy test cases:

Other than functional testing, we may need to verify the accuracy/correctness of the sorting algorithm under test. There are multiple ways of achieving the same. I am listing those below:

1. Compare each element to the next element until we compare all the element to verify that each element is less than or equal to the next element if sorting order is ascending.

2. Source array and result array should have same size.

3. All the element in source array should be present in result array

4. Construct the sorted array and compare this with the result of the array returned by the sorting algorithm

Performance test cases:

Let us try few performance test cases as listed below:

1. Run the algorithm with a small data test with best case, average case and worst case scenarios

and measure the running time

2. Run the algorithm with a big data test with best case, average case and worst case scenarios and measure the running time

Reliability test cases:

Finally end testing cycle with few reliability test cases as well.

1. Run the algorithm for multiple times for example 100 time, running continuously for a day, running continuously for a week etc to uncover any reliability issue like memory leak, CPU usage etc.

2. Measure the failure rate if any.

Did i miss any thing? Please add your comments.