(a)
CFG:
(b) 当MAXPRIMES的值为4的时候。t2会造成数组越界的错误。
(c) n = 1
(d) Node Coverage:
TR{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
Test Path={[1,2,3,4,5,7,9,5,6,10,12,3,13,14,15,13,16]
[1,2,3,4,5,7,8,6,10,11,12,3,13,16]}
Edge Coverage:
TR{[1,2],[2,3],[3,4],[3,13],[4,5],[5,7],[5,6],[7,9],[7,8],[9,5],[8,6],[6,10],[10,11],
[10,12],[11,12],[12,3],[13,14],[14,15],[15,13],[13,16]}
Test Path = {[1,2,3,4,5,7,9,5,6,10,12,3,13,14,15,13,16]
[1,2,3,4,5,7,8,6,10,11,12,3,13,16]}
Prime Path Coverage:
TR{[1,2,3,4,5,7,9], [1,2,3,4,5,7,8,6,10,12],[3,4,5,6,10,11,12,3]
[3,4,5,7,8,6,10,11,12,3],[3,4,5,6,10,12,3],[3,4,5,6,10,12,3]
[5,7,9,5][7,9,5,7][9,5,7,9]
[7,9,5,6,10,12,3,13,16],[7,9,5,6,10,12,3,13,14,15],[7,9,5,6,10,11,12,3,13,16],[7,9,5,6,10,11,12,3,13,14,15]
[9,5,7,8,6,10,12,3,13,16],[9,5,7,8,6,10,12,3,13,14,15],[9,5,7,8,6,10,11,12,3,13,16]
[9,5,7,8,6,10,11,12,3,13,14,15]
[1,2,3,13,16][1,2,3,13,14,15]
[13,14,15,13][14,15,12,14],[15,13,14,15][14,15,13,16]
选择其中一条主路径测试:
测试结果: