软件测试-素数打印
(a)
(b)将while循环中嵌套的for循环去掉,只检验一次Divisible(primes[i],curPrime)
(c)测试用例为t=(n = 1)
(d)节点覆盖
TP | TR |
[1,2,3,4,5,6,11,5,8,10,3,12,13,14,15,13,16] | {1,2,3,4,5,6,10,11,23,13,14,15,16} |
[1,2,3,4,5,6,7,8,10,12,13,16] | {1,2,3,4,5,6,7,8,10,12,13,16} |
边覆盖
TP | TR |
[1,2,3,4,5,6,11,5,8,10,3,12,13,16] | {[1,2],[2,3],[3,4],[4,5],[5,6],[6,11],[11,5],[5,8],[8,10],[10,3],[3,12],[12,13],[13,16]} |
[1,2,3,4,5,6,7,8,9,10,3,12,13,14,15,13,16] | {[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,3],[3,12],[12,13],[13,14],[14,15],[15,13],[13,16]} |
主路径覆盖
TR |
|
[1,2,3,4,5,6,11] |
|
[1,2,3,4,5,6,7,8,9,10] |
|
[1,2,3,4,5,6,7,8,10] |
|
[1,2,3,4,5,8,9,10] |
|
[1,2,3,4,5,8,10] |
|
[1,2,3,12,13,14,15] |
|
[1,2,3,12,13,16] |
|
[4,5,6,7,8,9,10,3,12,13,16] |
|
[4,5,6,7,8,9,10,3,12,13,14,15] |
|
[4,5,6,7,8,10,3,12,13,14,15] |
|
[4,5,6,7,8,10,3,12,13,16] |
|
[4,5,8,9,10,3,12,13,16] |
|
[4,5,8,9,10,3,12,13,14,15] |
|
[4,5,8,10,3,12,13,16] |
|
[4,5,8,10,3,12,13,14,15] |
|
[4,5,8,9,10,3,4] |
|
[4,5,8,10,3,4] |
|
[5,6,11,5] |
|
[5,6,7,8,9,10,3,4,5] |
|
[5,6,7,8,10,3,4,5] |
|
[5,8,9,10,3,4,5] |
|
[5,8,10,3,4,5] |
|
[6,7,8,9,10,3,4,5,6] |
|
[6,7,8,10,3,4,5,6] |
|
[6,11,5,6] |
|
[6,11,5,8,9,10,3,4] |
|
[6,11,5,8,9,10,3,12,13,16] |
|
[6,11,5,8,9,10,3,12,13,14,15] |
|
[6,11,5,8,10,3,4] |
|
[6,11,5,8,10,3,12,13,16] |
|
[6,11,5,8,10,3,12,13,14,15] |
|
[7,8,9,10,3,4,5,6,11] |
|
[7,8,9,10,3,4,5,6,7] |
|
[7,8,10,3,4,5,6,11] |
|
[7,8,10,3,4,5,6,7] |
|
[8,9,10,3,4,5,8] |
|
[8,9,10,3,4,5,6,7,8] |
|
[8,10,3,4,5,8] |
|
[8,10,3,4,5,6,7,8] |
|
[9,10,3,4,5,6,7,8,9] |
|
[11,5,6,11] |
|
[11,5,6,7,8,9,10,3,4] |
|
[11,5,6,7,8,9,10,3,12,13,16] |
|
[11,5,6,7,8,9,10,3,12,13,14,15] |
|
[11,5,6,7,8,10,3,4] |
|
[11,5,6,7,8,10,3,12,13,16] |
|
[11,5,6,7,8,10,3,12,13,14,15] |
|
[13,14,15,13] |
|
[14,15,13,14] |
|
[15,13,14,15] |
|
实现如上。