标签:
public static void printPrimes (int n) { int curPrime; int numPrimes; boolean isPrime; int [] primes = new int [MAXPRIMES]; primes [0] = 2; numPrimes = 1; curPrime = 2; while (numPrimes < n) { curPrime++; isPrime = true; for (int i = 0; i <= numPrimes-1; i++) { if (curPrime%primes[i]==0) { isPrime = false; break; } } if (isPrime) { primes[numPrimes] = curPrime; numPrimes++; } } for (int i = 0; i <= numPrimes-1; i++) { System.out.println ("Prime: " + primes[i]); }
一、控制流图
二、测试用例t1=(n=3),和t2=(n=5),t2容易发生二t1不容易发生的错误是:数组越界问题。
三、n=1时,相应的测试路径访问连接while语句开始到for语句的边,而不用通过while循环体。
四、节点覆盖:{0,1,2,3,4,5,6,7,8,9,10,11,12}
边覆盖:{(0,1),(1,2),(2,3),(3,4),(4,5),(5,7),(4,6),(3,7),(7,9),(6,3),(7,8),(8,9),(1,9),(9,10),(10,11),(11,10),(10,12)}
主路径覆盖:{(0,1,2,3,4,5,7,8,9,10,11,),(0,1,2,3,4,5,7,8,9,10,12),(0,1,2,3,4,5,7,9,10,11),(0,1,2,3,4,5,7,9,10,12),(0,1,2,3,4,6),
(0,1,9,10,12),(10,11,10),(11,10,11),(3,4,6,3),(4,6,3,4),(6,3,4,6)}
五、主路径覆盖截图
标签:
原文地址:http://www.cnblogs.com/xiao94/p/5332252.html