【SoftwareTestingHomework3】--3013218086--

2.设计数组越界错误,n越大,越可能越界
3.设n=1
4.
- 节点覆盖
- [0,1,2,3,4,5,3,4,6,7,8,1,9,10,11,10,12]
- 边覆盖
- [0,1,2,3,4,6,7,8,1,9,10,11,10,12]
- [0,1,2,3,4,5,3,7,1,9,10,12]
- 主路径覆盖
- [0,1,2,3,4,5]
- [0,1,2,3,4,5,7,8]
- [0,1,2,3,7,8]
- [0,1,9,10,11]
- [0,1,9,10,12]
- [3,4,5,3]
- [4,5,3,4]
- [5,3,4,5]
- [5,3,4,6,7,8,1,2]
- [5,3,4,6,7,8,1,9,10,11]
- [5,3,4,6,7,8,1,9,10,12]
- [5,3,7,8,1,2]
- [5,3,7,8,1,9,10,11]
- [5,3,7,8,1,9,10,12]
- [10,11,10]
- [11,10,11]
5.实现主路径覆盖
代码
public class Triangle {
public int a;
public int b;
public int c;
public Triangle(int a,int b,int c)
{
this.a=a;
this.b=b;
this.c=c;
}
public String judge() {
if(a==b&&b==c)
return "equilateral";
else if(a==b||b==c||c==a)
return "isosceles";
else {
return "scalene";
}
}
}
实现
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class TestTriangle {
Triangle tri =null;
@Before
public void setUp() throws Exception {}
@After
public void tearDown() throws Exception {}
@Test
public void test() {
tri = new Triangle(3,3,3);
assertEquals("equilateral",tri.judge());
tri = new Triangle(2,3,3);
assertEquals("isosceles",tri.judge());
tri = new Triangle(3,4,5);
assertEquals("scalene",tri.judge());
}
}

浙公网安备 33010602011771号