3014218152 林默涵 HW3

Posted on 2017-03-14 21:49  tjulmh  阅读(113)  评论(0)    收藏  举报

a.

 

 

 

b. when MAXPRIMES equals 4, the program will access the outer part of the array.

 

c. n= 1.

 

d. node coverage

{1,2,3,4,5,6,7,8,9,10,11,12,13}

 

Edge coverage

{(1,2),(2,3),(2,10),(3,4),(4,5),(4,8),(5,6),(5,7),(6,4),(7,8),(8,2),(8,9),(9,2),(10,11),(11,12),(11,13),(12,11)}

 

Test Paths:[1,2,3,4,5,6,4,5,7,8,9,2,10,11,12,11,13],[1,2,3,4,8,2,10,11,13]

 

Prime Path Coverage

[11,12,11], [12,11,12], [4,5,6,4], [5,6,4,5], [6,4,5,6], ,[1,2,10,11,12], [1,2,10,11,13], [2,3,4,8,2], [3,4,8,2,3], [4,8,2,3,4] ,[8,2,3,4,8] ,[8,2,3,4,8] ,[1,2,3,4,8,9] ,[2,3,4,8,9,2] [3,4,8,9,2,3] ,[4,8,9,2,3,4] ,[5,6,4,8,2,3] ,[8,9,2,3,4,8] ,[9,2,3,4,8,9] ,[2,3,4,5,7,8,2] ,[3,4,5,7,8,2,3] ,[4,5,7,8,2,3,4] ,[5,6,4,8,9,2,3] ,[5,7,8,2,3,4,5] ,[6,4,5,7,8,2,3] ,[7,8,2,3,4,5,6] ,[7,8,2,3,4,5,7] ,[8,2,3,4,5,7,8], [1,2,3,4,5,7,8,9] ,[2,3,4,5,7,8,9,2] ,[4,5,7,8,9,2,3,4] ,[5,6,4,8,2,10,11,12] ,[5,6,4,8,2,10,11,13] ,[5,7,8,9,2,3,4,5] ,[6,4,5,7,8,9,2,3] ,[7,8,9,2,3,4,5,6] ,[7,8,9,2,3,4,5,7],[8,9,2,3,4,5,7,8],[9,2,3,4,5,7,8,9],[3,4,5,7,8,2,10,11,12],[3,4,5,7,8,2,10,11,13] ,[5,6,4,8,9,2,10,11,12],[5,6,4,8,9,2,10,11,13],[6,4,5,7,8,2,10,11,12],[6,4,5,7,8,2,10,11,13],[3,4,5,7,8,9,2,10,11,12],[3,4,5,7,8,9,2,10,11,13],[6,4,5,7,8,9,2,10,11,12],[6,4,5,7,8,9,2,10,11,13].

 

Test code:

import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class printPrimeTest {
    public printPrime tPrime = new printPrime();
    @Before
    public void setUp() throws Exception {    
    }
    @Test
    public void testPrintPrimes() {
        assertEquals("2 3 5 ", tPrime.printPrimes(3));
        System.out.println(tPrime.printPrimes(3));
    }
}

 

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3