码迷,mamicode.com
首页 > 其他好文 > 详细

软件测试homework3的主路径覆盖

时间:2016-03-31 12:22:54      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

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的主路径覆盖

标签:

原文地址:http://www.cnblogs.com/tzy3013218117/p/5340373.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!