为以下程序设计三组测试用例,要求分别满足语句覆盖、判定覆盖、条件覆盖。
时间: 2023-11-22 10:04:12 浏览: 50
以下是待测程序的伪代码:
```
1. read a
2. read b
3. if a > 0 and b > 0 then
4. if a > b then
5. print "a is greater than b"
6. else
7. print "b is greater than a"
8. else
9. print "a and b must be positive numbers"
10. end if
```
针对该程序,设计如下三组测试用例:
**语句覆盖**
测试用例1:
```
Input:
a = 3
b = 2
Output:
"a is greater than b"
```
测试用例2:
```
Input:
a = -1
b = 4
Output:
"a and b must be positive numbers"
```
测试用例3:
```
Input:
a = 0
b = 0
Output:
"a and b must be positive numbers"
```
**判定覆盖**
测试用例1:
```
Input:
a = 3
b = 2
Output:
"a is greater than b"
```
测试用例2:
```
Input:
a = -1
b = 4
Output:
"a and b must be positive numbers"
```
测试用例3:
```
Input:
a = 2
b = 3
Output:
"b is greater than a"
```
**条件覆盖**
测试用例1:
```
Input:
a = 3
b = 2
Output:
"a is greater than b"
```
测试用例2:
```
Input:
a = -1
b = 4
Output:
"a and b must be positive numbers"
```
测试用例3:
```
Input:
a = 2
b = 3
Output:
"b is greater than a"
```
测试用例4:
```
Input:
a = 0
b = 5
Output:
"a and b must be positive numbers"
```
测试用例5:
```
Input:
a = 4
b = 0
Output:
"a and b must be positive numbers"
```
测试用例6:
```
Input:
a = -1
b = -2
Output:
"a and b must be positive numbers"
```
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](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)