user3223190
user3223190

Reputation: 153

Testing Sorting arrays

Hi I have problem with how to test my sort arrays. I have no problem in the coding of them however we are supposed to develop "smart" test cases. To test the sorting methods.

I dont get what the smart cases would be. I know if I was developing a calender a smart thest case would be the last day of the year etc. However I dont understand it for sorting.

The only thing I can think of would be the middle element the first and the last.

I dont want any code just some feedback on what you thing smart cases would be.

Upvotes: 1

Views: 46

Answers (2)

Valdrinium
Valdrinium

Reputation: 1416

You could try to sort in increasing order:

  1. a sorted array
  2. an almost sorted array( only a few swaps would sort it )
  3. a random array
  4. an almost sorted array in decresing order
  5. a sorted array in decreasing order

Afetr analising the performance on those, you could try:

  1. random array with many duplicates

Upvotes: 1

loopbackbee
loopbackbee

Reputation: 23322

If you're checking for correctness, you may want to try:

  • a reversed order array: [5,4,3,2,1]
  • a array with repeated elements [1,1,3,3,2,2]
  • a array with only repeated elements [1,1,1,1,1]
  • arrays with odd and even number of elements

If you're going to use associative arrays, you may want to check for stability.

If you're checking for runtime complexity, you may also want to try longer arrays.

Upvotes: 1

Related Questions