Following is the prototype of a function to find the index of the key value in an array. It returns -1 if the key is not found.
int search(int array[ ], int arraySize, int key);
(a) Identify equivalence partitions to devise black-box test cases for this function. (5 Pts)
(b) Write test cases against each partition identified in part (a). (5 Pts)
Show answerJawab dekhein
(a) Partitions: arraySize invalid (negative); empty array (arraySize = 0); one-element array with key present / key absent; many-element array with key at the first position, at the last position, in the middle, key absent; key appearing more than once.
(b) Test cases: {array=[], size=-1, key=3} -> error/-1; {[], 0, 3} -> -1; {[5], 1, 5} -> 0; {[5], 1, 3} -> -1; {[4,7,9,2], 4, 4} -> 0; {[4,7,9,2], 4, 2} -> 3; {[4,7,9,2], 4, 9} -> 2; {[4,7,9,2], 4, 8} -> -1; {[4,7,4,2], 4, 4} -> 0 (first match, as specified). Values at the boundaries of the int range can also be used as keys.