Software Test Study notes: Master Path Test

Source: Internet
Author: User

(a)

(b) When the Maxprimes is set to 2 to 5 directly. T2= (n=5) will appear out of bounds error and t1= (n=3) will not

(c) When n=0 or 1 o'clock, the program does not pass through the while loop.

(d)

Node Overlay

tr= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}

Edge Overlay

tr= {(), (2,3), (3,4), (4,5), (5,6), (6,7), (7,5), (6,8), (8,9), (5,9),

(9,10), (9,11), (10,11), (11,12), (2,12), (12,13), (13,16), (13,14), (14,15), (15,13)}

Master Path overrides

tr= {[1,2,3,4,5,6,8,9,10,11],[1,2,3,4,5,6,8,9,11],[1,2,3,4,5,6,7],[1,2,3,4,5,9,10,11],[1,2,3,4,5,9,11],[ 1,2,12,13,16],[1,2,12,13,14,15],

[2,3,4,5,6,8,9,10,11,2],[2,3,4,5,6,8,9,11,2],[2,3,4,5,9,10,11,2],[2,3,4,5,9,11,2],

[3,4,5,6,8,9,10,11,2,12,13,16],[3,4,5,6,8,9,10,11,2,12,13,14,15],[3,4,5,6,8,9,11,2,12,13,16],[ 3,4,5,6,8,9,11,12,13,14,15],[3,4,5,9,10,11,2,12,13,16],[3,4,5,9,10,11,2,12,13,14,15],[3,4,5,9,11,2,12,13,16],[ 3,4,5,9,11,2,12,13,14,15],[3,4,5,6,8,9,10,11,2,3],[3,4,5,6,8,9,11,2,3],[3,4,5,9,10,11,2,3],[3,4,5,9,11,2,3],

[4,5,6,8,9,10,11,2,3,4],[4,5,6,8,9,11,2,3,4],[4,5,9,10,11,2,3,4],[4,5,9,11,2,3,4],

[5,6,8,9,10,11,2,3,4,5],[5,6,8,9,11,2,3,4,5],[5,9,10,11,2,3,4,5],[5,9,11,2,3,4,5],[5,6,7,5],

[6,8,9,10,11,2,3,4,5,6],[6,8,9,11,2,3,4,5,6],[6,7,5,6],[6,7,5,9,10,11,2,3,4,5,6],[6,7,5,9,11,2,3,4,5,6],[ 6,7,5,9,10,11,2,12,13,16],[6,7,5,9,10,11,2,14,15],[6,7,5,9,11,2,12,13,16],[6,7,5,9,11,2,14,15],

[7,5,6,7],[7,5,6,8,9,10,11,2,3,4],[7,5,6,8,9,11,2,3,4],[7,5,6,8,9,10,11,2,12,13,16],[7,5,6,8,9,11,2,12,13,16], [7,5,6,8,9,10,11,2,12,13,14,15],[7,5,6,8,9,11,2,12,13,14,15],

[8,9,10,11,2,3,4,5,6,8],[8,9,11,2,3,4,5,6,8],

[9,10,11,2,3,4,5,6,8,9],[9,11,2,3,4,5,6,8,9],

[10,11,2,3,4,5,6,8,9,10],[10,11,2,3,4,5,9,10],

[11,2,3,4,5,6,8,9,10,11],[11,2,3,4,5,9,10,11],[11,2,3,4,5,6,8,9,11],[11,2,3,4,5,9,11],

[13,14,15,13],[14,15,13,14],[14,15,13,16],[15,13,14,13],[15,13,16]}

Master Path Overlay Test:

First add the Isdivisable () method and alter the Printprimes () method. Put the output into an int array:

First add isdivisable () and modify the Printsprimes function to output the result to the array

 Public classPrimes {Private Static Final intMaxprimes = 100; /******************************************************* * Finds and prints n prime integers * Jeff Offutt, SPR ING 2003 ******************************************************/      Public Static int[] 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(Isdivisable (primes[i],curprime)) {//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]); }         returnprimes; } //End Printprime        Static BooleanIsdivisable (intPrimesintcurprime) {        Booleanresult =false; intMoD = curprime%primes; if(mod== 0) {result=true; }        returnresult; }}

The test class code is as follows:

Import Staticorg.junit.assert.*;ImportOrg.junit.Before;Importorg.junit.Test; Public classPrimestest {Private StaticPrimes prime =NULL; Private Static int[] Primearray =New int[100]; @Before Public voidSetUp ()throwsException {Prime=NewPrimes (); primearray[0] = 2; primearray[1] = 3; primearray[2] = 5; primearray[3] = 7; primearray[4] = 11; } @Test Public voidTestprintprimes () {assertarrayequals (Primearray, Prime.printprimes (5)); }}

The results of the operation are as follows:

Software Test Study notes: Master Path Test

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.