7. Which test case below can kill the mutant?
Mutant:
int x = read(); // x is the input
x = 2*x;
if (x > 5){
printf(“%d”, x);
}else{
print(“%d”, x/2); // Original: print(“%d”, x-2);
}
A. x = 4
B. x = 3
C. x = 2
D. x = 1
D) x = 1 is the answer.
A mutant is said to be killed, when the test suite is able to detect the changes.
Here we are performing Mutation testing by changing the operator '-' with '/'.
We have to calculate output for both the operators '-' and '/' with four inputs(1,2,3,4). If the outputs are same in both cases, Mutant is not killed.
Let's check this out
O/P using '/' operator O/P using '-' operator
x = 4 8 8 (No change)
x = 3 6 6 (No change)
x = 2 2 2 (No change)
x = 1 1 0 (Change)
Get Answers For Free
Most questions answered within 1 hours.