Software Test Technology Job 2

Source: Internet
Author: User

1   Public intFindLast (int[] x,inty) {2 //effects:if X==null Throw3 NullPointerException4 //else return the index of the last element5 //In x that equals Y.6 //If No such element exists, return-17  for(inti=x.length-1; i >0; i--)8 {9 if(X[i] = =y)Ten { One returni; A } - } - return-1; the } - //test:x=[2, 3, 5]; y = 2 - //expected = 0

Error:

for (int i=x.length-1; i > 0; i--)

should read
for (int i=x.length-1; i >= 0; i--)//The No. 0 data in the array is not traversed in the original code

Use cases that do not fail: x = [2,3,5];y = 5; excepted = 2;

Test cases that fail but do not cause an error state:??

A test case that causes a failure without failure: x = [2,3,5];y = 0; excepted =-1;

1  Public Static intLastzero (int[] x) {2 //effects:if X==null Throw3 NullPointerException4 //else return the index of the last 0 in X.5 //Return-1 If 0 does not occur in X6  for(inti =0; i < x.length; i++)7 {8 if(X[i] = =0)9 {Ten returni; One } A}return-1; - } - //test:x=[0, 1, 0] the //expected = 2

Error:

for (int i = 0; i < x.length; i++)

should read
for (int i = x.length-1; I >= 0; i--)//The original code searches for the first 0 in the array rather than the last
Test cases that do not fail:??

Test cases that fail but do not cause an error state:??

Test cases that cause failure without failure: x = [1,0,1]; expected = 1;




Knowledge Points:
    • Software failure (software Fault): Defects in the static code in the software
    • Software error (software error): Incorrect internal state, which is the performance of the failure.
    • Software failure (software Failure): A description of a requirement or expected behavior about Del, external, incorrect behavior
Reachability: The wrong location in the project can be found
Infection: The stage in the project must be incorrect
Propagation: An affected part of a project must cause some output or incorrect results

Software Test Technology Job 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.