软件测试homework3的主路径覆盖

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了软件测试homework3的主路径覆盖相关的知识,希望对你有一定的参考价值。

package test;

public class test {
    void printPrimes(int n){
        int curPrime;
        int numPrimes;
        boolean isPrime;
        int [] primes = new int [43];
        primes[0]=2;
        numPrimes = 1;
        curPrime = 2;
        while ( numPrimes < n)
        {
            curPrime ++ ;
            isPrime = true;
            for ( int i = 0 ; i <= numPrimes-1 ;i++){
                if (isDivisible(primes[i],curPrime))
                {
                    isPrime = false;
                    break ;
                }
            }
            if (isPrime){
                primes[numPrimes] = curPrime ;
                numPrimes ++ ;
                
            }
        }
        
        for (int i = 0 ; i <= numPrimes -1 ; i++ )
        {
            System.out.println("Prime: " + primes[i]);
        }
        
    }

    boolean isDivisible(int i, int curPrime) {
        if ( curPrime % i == 0 )
            return true;
        return false;
    }
}
package test;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class testTest {
    private test t= null;
    @Before
    public void setUp() throws Exception {
        t = new test ();
    }

    @Test
    public void test() {
        t.printPrimes(0);
        t.printPrimes(3);
        t.printPrimes(5);
    }

}

 

以上是关于软件测试homework3的主路径覆盖的主要内容,如果未能解决你的问题,请参考以下文章

软件测试homework3

SoftwareTest homework3

Homework3

软件测试,Homework3

软件测试homework3

软件测试homework3