画出下列代码段对应的程序流程图,并设计一组测试用例,要求满足判定/条件覆盖和条件组合覆盖。 int test(int A, int B) { Int X=0; if ((A>1) and (B<10)) then X=A-B; if ((A=1) or (B>20)) then X=A+B; return X; }
时间: 2024-01-30 20:02:58 浏览: 178
程序流程图如下:
```
+-------------------+
| Start |
+-------------------+
|
| (A>1) and (B<10)
v
+-------------------+
| X=A-B |
+-------------------+
|
| (A=1) or (B>20)
v
+-------------------+
| X=A+B |
+-------------------+
|
v
+-------------------+
| Return X |
+-------------------+
|
v
+-------------------+
| End |
+-------------------+
```
测试用例设计如下:
判定/条件覆盖:
| Test Case | A | B | Expected Output |
|-----------|-------|-------|----------------|
| TC1 | 0 | 10 | 0 |
| TC2 | 2 | 9 | -7 |
| TC3 | 1 | 21 | 22 |
条件组合覆盖:
| Test Case | A | B | Expected Output |
|-----------|-------|-------|----------------|
| TC1 | 2 | 9 | -7 |
| TC2 | 2 | 21 | 23 |
| TC3 | 1 | 9 | -8 |
| TC4 | 1 | 21 | 22 |
阅读全文