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