Black box tests for insertion procedure
If I read this function correctly, any input with this property a [0]> a [2] will be detected
First cycle through for (i=2; i<=N; i++)
Tracking variables in my head.
-
i = 2
-
k = p[i] == 2
-
j = 1
-
p[j-1] = p[0] == 0
- Since the
a[0] > a[2]
while condition is true, soj-- == 0
- The following evaulation while operation will do: -
while (a[p[-1] > k)
> SEGFAULT
This might be a good test :-)
It doesn't look like there is any useful input that would force this if the loop ran more than once without a segfault, so I would say there is a logic error in there.
a source to share
I would start with these
- negative number in []. What should be the result?
- negative number in p [].
- negative number N.
- empty array.
- an empty array p.
- N = 0
Looking at the implementation (I'm not programming in c), I suspect some of them will be AV.
In a nutshell, you should at least do a boundary analysis of your inputs and device to test each parameter with every value out of bounds, on bounds, and in.
Example
If you have 1 parameter and define boundaries 0 and 10, this should result in 6 test files. You should go to -1, 0, 1, 9, 10 and 11.
Further Study
As the number of parameters increases, it quickly becomes impossible to test combinations of everything . This is where testing all pairs comes in handy.
a source to share