After class 1.2, practice the third question.
The first paragraph of the procedure:
(a) The For loop does not traverse the first element of the array, that is, element No. 0, which is corrected to
for int i = x.length-1; I >= 0; I--) {...}
(b) If you want to throw a null pointer error without performing a fault, then if the x array is empty. Give a set of possible test cases
null ; y = = 1; Expected output: NullPointerException; Actual output: NullPointerException;
(c) A test case that performs a failure but does not result in an error state, and it is necessary to ensure that the last value of y appears in the first position of the array, giving a set of possible test cases:
x = = [10, 11, 12]; y = = one; Expected output:1 actual output:1
(d) If a set of data after the above algorithm, will result in errors rather than failures, then y corresponding values must not appear in the X array, give a set of possible test cases
x = = [Ten, one, one] y == 1-1
The second paragraph of the procedure:
(a) The For loop should traverse forward from the end of the array, so it is convenient to find the last 0 position.
for int i = x.length-1; I >= 0; I--) {...}
(b) All test cases will fail.
(c) If the array length is 0 o'clock, the for loop will not execute at all, and no error will occur; When the array length is 1 o'clock, the loop executes only once, at which point the final result is the same regardless of the sequential or reverse traversal, so there is no error.
x = = [all ]- 1-1
(d) Because the code in the title is sequential traversal rather than reverse, so as long as the loop goes more than once, then there will be an error, want not to cause failure, then the test case needs to have 0 or 0, so that the final output is not the order of the traversal is irrelevant
x = = [One, 1 , 1]
"Software testing homework 2"