A<5)and(B=5) X=X/A (A=2)or(X>2) X=X+1完成以下要求: (1)用语句覆盖写测试用例(2)用判定覆盖设计测试用例(3)用条件覆盖设计测试用例(4)用判定/条件覆盖设计测试用 例 (5)用多重条件覆盖设计测试用例(6)用路径覆盖设计测试用例
时间: 2023-10-11 16:08:14 浏览: 27
1. 测试用例(语句覆盖):
A = 4, B = 5, X = 6
2. 测试用例(判定覆盖):
A = 2, B = 5, X = 1
3. 测试用例(条件覆盖):
(A < 5) and (B = 5), X = 3
4. 测试用例(判定/条件覆盖):
(A = 2) and (X ≤ 2), A = 2, B = 5, X = 1
5. 测试用例(多重条件覆盖):
(A = 2) and (X ≤ 2), A = 3, B = 6, X = 4
6. 测试用例(路径覆盖):
路径1: A < 5, B = 5, X = X/A, A = 2, X > 2, X = X
测试用例:A = 2, B = 5, X = 6
路径2: A < 5, B = 5, X = X/A, A = 2, X ≤ 2, (A = 2) or (X > 2), X = X
测试用例:A = 2, B = 5, X = 1
路径3: A < 5, B ≠ 5, X = X/A, X = X
测试用例:A = 3, B = 6, X = 8
相关问题
已知:a,+b,+c,+d+=+1,+2,+3,+0++表达式d+<+b+or+c+>+a+++b+++d+and+b+<+c+++a的值为(++)。
根据给出的表达式,我们可以逐步计算其值:
1. 首先,根据运算符的优先级,我们先计算括号内的表达式:(+1) + (+2) + (+3) + (+0) = 6。
2. 接下来,我们计算d + < + b + or + c + > + a + ++b + ++d + and + b + < + c + ++a。根据运算符的优先级,我们从左到右进行计算。
- 首先,计算d + < + b,这里的<是一个比较运算符,表示小于。假设d的值为x,b的值为y,则这个表达式的结果为x < y。
- 然后,计算or运算符,它表示逻辑或。假设x < y的结果为p,c的值为q,则这个表达式的结果为p or q。
- 接着,计算>运算符,它表示大于。假设a的值为m,p or q的结果为r,则这个表达式的结果为r > m。
- 然后,计算++b,这里的++是一个自增运算符,表示将b的值加1。假设b的值为n,则这个表达式的结果为n+1。
- 接着,计算++d,假设d的值为x,则这个表达式的结果为x+1。
- 然后,计算and运算符,它表示逻辑与。假设n+1的结果为s,则这个表达式的结果为r > m and s。
- 最后,计算b < c,假设c的值为z,则这个表达式的结果为n+1 < z。
3. 综上所述,整个表达式的值为(n+1 < z)。
写出下面表达式的值(设a=1,b=2,c=3,x=4,y=3)。 ( 1) a+b>c and b==c (2) not a<b and b not =c or x+y<=3 (3) a+( b>=x+y) and c-a and y-x (4) not(x=a) and(y=b) and 0 (5) not( a+b)+c-1 and b+c/2 (6)a or 1+‘a’ and b and ‘c’
(1) False,因为a+b=3不大于c=3,且b不等于c。
(2) False,因为a<b,所以not a<b为False,b不等于c,所以b not =c为True,x+y=7不小于等于3,所以x+y<=3为False,False or True为True,但not True为False。
(3) 0,因为b>=x+y为False,所以a+( b>=x+y)为a+False=1,c-a为3-1=2,y-x为-1,2*(-1)=-2。
(4) True,因为x不等于a,y等于b,0为True。
(5) False,因为not(a+b)为False,c-1为2,b+c/2为3.5,False and 3.5为False。
(6) True,因为a为1,1 or True为True,1+'a'为非法表达式,不过由于or运算符的短路特性,不需要计算后面的表达式,直接返回True。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)