12. (8 points) Given the below code and 2 mutants (X and Y) answer the following
ID: 654486 • Letter: 1
Question
12. (8 points) Given the below code and 2 mutants (X and Y) answer the following questions for each mutant.
int max (int A, int B)
{
int maxVal;
maxVal = B; /* X */
if (B < A)
{
maxVal = A; /* Y */
}
return (maxVal);
}
Mutants X and Y:
(X) maxVal = B; // Original
maxVal = A; // Mutant X
(Y) maxVal = A; // Original
maxVal = B; // Mutant Y
(a) If possible, find values for integers A and B where cannot reach the mutant. If there are no such values, explain why. (Answer for each mutant X and Y)
(b) If possible, find values for integers A and B where can satisfy reachability but not infection for the mutant. If there are no such values, explain why. (Answer for each mutant X and Y)
(c) If possible, find values for integers A and B where can satisfy infection, but not propagation for the mutant. If there are no such values, explain why. (Answer for each mutant X and Y)
(d) Provide reachability conditions, infection conditions, propagation conditions, and test case values to kill the mutant. (Answer for each mutant X and Y)
Explanation / Answer
(a) X: If (B>A), maxval=B is original and not mutant
Y: If (B<A) or (A>B), maxval= A
(b) X: For maxval=B, Reachability is (B>A) or (B !< A)
Y: For Maxval= A, Reachability is (B<A)
(c) Infection will be satisfied without propagation when A and B will have other than original values.
For example: If (A==B) or (A>=B) or (A<=B)
(d) Reachability to kill the mutant means Original values should be maintained. So, Reachability Conditions are:
X: If (A<B), Maxval=B
Y: If (B<A), Maxval=A
Infection Conditions: When result will be different from originals.
X: If (A>B)
Y: If (B>A)
Propagation Conditions:
X: If (B!<A)
: If (B!=A)
Y: If (B!>A)
: If(True)
Test Case values:
If(B>=A) kill
If(B<A) or (B>A) live
If (B<=A) or (B>=A) kill
If(B==A) Kill
If (B!=A) Propagation
If(False) Kill
If(True): Propagation
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.