Question

Consider the following method 1. double calculateMin(int A, int B){ 2. int minVal = A; 3. if (B&l...

Consider the following method

1. double calculateMin(int A, int B){

2. int minVal = A;

3. if (B<A){

4. minVal = B;

5. }

6. return minVal; 7.

7. }

Describe two mutation operators and use them to create two mutants.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

First mutation operators can be operands A and B
First mutant if where we interchange operand A and B as below
double calculateMin(int A, int B){
int minVal = A;
if (A<B){
minVal = B;
}
return minVal;
}

The above code will now always return the largest of the two numbers A and B as such the test case will fail

=====================================================================================

Second mutation operators can be B<A, here we change less than operator to greater than operator
double calculateMin(int A, int B){
int minVal = A;
if (B>A){
minVal = B;
}
return minVal;
}

The above code will now always return the largest of the two numbers A and B as such the test case will fail

Add a comment
Know the answer?
Add Answer to:
Consider the following method 1. double calculateMin(int A, int B){ 2. int minVal = A; 3. if (B&l...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT