软件工程第三次作业
一、编写测试类
代码如下:
public class Homework3{
public int MAX(int n,int[] c)
{
int[] b=new int[100];
b[0]=c[0];
int Max=0;
for(int i=1;i<n;i++)
{
if(b[i-1]>0)
b[i]=b[i-1]+c[i];
else
b[i]=c[i];
if(b[i]>Max)
Max=b[i];
}
return Max;
}
}
二、测试程序
import static org.junit.Assert.*;
import org.junit.Test;
public class Homework3Test {
@Test
public void testMain() {
int[] a=new int[]{-4,11,-4,13,-5,-1};
int s=new Homework3().MAX(6,a);
assertEquals(20,s);
}
@Test
public void testMain1() {
int[] a1=new int[]{-4,11,-4,13,-5,-16,4,5,-1,15,-4};
int s1=new Homework3().MAX(11,a1);
assertEquals(23,s1);
}
}
三、选用判定/条件覆盖的测试结果
[代码]https://coding.net/u/A18041362479/p/softwareengineering3/git/blob/master/.gitignore?public=true