Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Consider the following Java function for computing the maximum value in an array: 1. static int maxVal(int [] arr) { 2. int i=arr. length 1;
Consider the following Java function for computing the maximum value in an array: 1. static int maxVal(int [] arr) \{ 2. int i=arr. length 1; 3. int result =arr[i]; 4. while (i>=0){ 5. if (arr[i]> result ){ 6. result =arr[i] 6'. result =arr[i+1] 7. 3 8. i 9. } 10. return result; \} Line 6' shows a mutant of line 6 (i.e., in the mutated program, line 6 is replaced with line 6'). Answer the following questions. When you are asked to give a test input, give a value for the input array arr, written using square brackets, e.g., [0,1,2]. Note that the value null and the empty array [] are not allowed as a solution for any of the questions below. (a) (5 points) If possible, give a test input and an expected return value that strongly kills the mutant. (Assume that the test function asserts that the value returned from maxVal () is the expected value.) Otherwise, state that no such input and return value exists. 6. resut =arr[i];6resut=arr[i+1]; testinput=[10,1,x][3,5,1]expectedretwen=5. (b) (5 points) If possible, give a test input that does not reach the mutant. Otherwise, state that no such input exists. (c) (5 points) If possible, find a test input that satisfies reachability but not infection for the mutant. Otherwise, state that no such input exists. For Mutation testing , infection is ats reached after reachability is satisfied. testinput000,00[3,5,1] (d) ( 5 points) If possible, find a test input that satisfies infection but not propagation for the mutant. Otherwise, state that no such input exists
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started