Input domain example

De Software testing
Ir para: navegação, pesquisa

Considering an integer type of 16 bits (2 bytes). The lowest possible input value is -32,768 and the highest is 32,767. Thus there are 65,536 possible inputs into this small software. Which test cases can detect the defect?

int blech(int j) {
	j = j - 1; // should be j = j + 1;
	j = j / 30000;
	return j;
}

Only four out of the possible 65,536 input values will find this fault:

Test Cases
Input(j) Expected Output Actual Result
-30000 0 -1
-29999 0 -1
30000 1 0
29999 1 0