"Software Testing Homework 2"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.