软件测试-HW2
学号:3014218066
姓名:马钰
第一段代码:
1.错误位置:for循环条件i>=0。i>0导致数组x[0]没有被访问。
2.当数组为空时,直接抛出异常,不执行错误代码。
3.text:x=[2,3,5];y=5
expected=2
result = 2
4.text:x=[2,3,5];y=6
expected=-1
result = -1
第二段代码:
1.错误位置:for循环条件改为:for(int i=x.length-1; i>=0; i--)原代码导致返回的i不一定是最后一个。
2.当数组为空时,直接抛出异常,不执行错误代码。
3.text:x=[0,1]
expected=0
result = 0
4.text:x=[2,3,5]
expected=-1
result = -1
原文:http://www.cnblogs.com/marin-kobe/p/6493334.html