Use the following method Printprimes () for questions a-f below

Source: Internet
Author: User

Use the following method printprimes ()For questions A-f Belowcode
/******************************************************* * Finds and prints n prime integers* Jeff Offutt, Spring 2003 ******************************************************/  Public Static void Printprimes(intN) {intCurprime;//Value currently considered for primeness    intNumprimes;//Number of primes found so far.    BooleanIsPrime;//Is Curprime prime?    int[] primes =New int[Maxprimes];//The list of prime numbers.    //Initialize 2 into the list of primes.primes [0] =2; Numprimes =1; Curprime =2; while(Numprimes < N) {curprime++;//Next number to consider ...IsPrime =true; for(inti =0; I <= numprimes-1; i++) {//For each previous prime.            if(curprime%primes[i]==0)             {//Found a divisor, curprime is not prime.IsPrime =false; Break;//out of loop through primes.}         }if(IsPrime) {//Save it!Primes[numprimes] = Curprime;         numprimes++; }     }//End while    //Print all the primes out.     for(inti =0; I <= numprimes-1; i++) {System. out.println("Prime:"+ primes[i]); } }//End Printprimes
Draw the control flow graph for the Printprime () method.

Consider test Cases ti = (n = 3) and t2 = (n = 5). Although these tour the same prime paths in Printprime (), they don ' t necessarily find the same faults. Design a simple fault that T2 would is more likely to discover than T1 would.

Maxprimes = 4 of the time

For Printprime (), find a test case such this corresponding test path visits the edge that connects the beginning of th E While statement-to-statement without going through the body of the while loop.

n = 1 of the time

Enumerate the test requirements for node coverage, Edge Coverage,and Prime path coverages for the path for Printprimes (). Node Covered
    • 0,1,2,3,4,5,6,7,8,9,10,11,12
Edge Overlay
    • [0, 1]
    • [1, 2]
    • [1, 9]
    • [2, 3]
    • [3, 4]
    • [3, 7]
    • [4, 5]
    • [4, 6]
    • [5, 7]
    • [6, 3]
    • [7, 1]
    • [7, 8]
    • [8, 1]
    • [9, 10]
    • [10, 11]
    • [10, 12]
    • [11, 10]
Master Path overrides
    • [0, 1, 2, 3, 4, 6]
    • [0, 1, 2, 3, 4, 6, 7, 8]
    • [0, 1, 2, 3, 7, 8]
    • [0, 1, 9, 10, 11]
    • [0, 1, 9, 10, 12]
    • [3, 4, 6, 3]
    • [4, 6, 3, 4]
    • [6, 3, 4, 6]
    • [6, 3, 4, 5, 7, 8, 1, 2]
    • [6, 3, 4, 5, 7, 8, 1, 9, 10, 11]
    • [6, 3, 4, 5, 7, 8, 1, 9, 10, 12]
    • [6, 3, 7, 8, 1, 2]
    • [6, 3, 7, 8, 1, 9, 10, 11]
    • [6, 3, 7, 8, 1, 9, 10, 12]
    • [10, 11, 10]
    • [11, 10, 11]
List test paths that achieve node coverage is not edge coverage ont the graph.
    • [0, 1, 2, 3, 4, 6, 3, 4, 5, 7, 8, 9, 1, 10, 11, 12, 13, 11, 14]
The List test paths that achieve edge coverage is the not prime path coverages on the graph.
    • [0, 1, 2, 3, 4, 6, 3, 7, 8, 9, 1, 2, 3, 4, 5, 7, 9, 1, 2, 3, 4, 6, 3, 4, 6, 3, 7, 8, 9, 1, 10, 11, 12, 13, 11, 12, 13, 11, 12, 13, 11, 14]

Use the following method Printprimes () for questions a-f below

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.