COMP5710 SQA Assignment 2

$30.00

Download Details:

  • Name: hw_2-ipbet6.zip
  • Type: zip
  • Size: 460.65 KB

Category:

Description

Rate this product

The purpose of this assignment is to reinforce the lecture material on structural testing,
independent paths, and path predicates. For each of the source code fragments below 1)
construct a set of independent paths through the source code fragment 2) construct a path
predicate for each independent path. You must use line numbers to describe the independent
paths and use Boolean conditions from the source code to describe the path predicates.
Example of response format is shown in Figure 1.
Example:
1. void Q0() {
2. if (C1) {
3. do {
4. S1;
5. if (C2) {
6. S2;
7. }
8. } while (C3);
9. S3;
10. } else {
11. S4;
12. while (C4) {
13. S5;
14. }
15. }
16. S6;
17. }
Answer:
V(G) = 5
Path # Path C1 C2 C3 C4
1 1-2-11-12-16 F X X F
2 1-2-11-12-13-12-16 F X X T/F
3 1-2-4-5-8-9-16 T F F X
4 1-2-4-5-6-8-9-16 T T F X
5 1-2-4-5-8-4-5-8-9-16 T F T/F X
Legend: T = true, F = false, X = irrelevant
Figure 1. Example showing response format
Problem 1:
1 void Q1(){
2 S1;
3 if(C1){
4 S2;
5 }
6 else{
7 S3;
8 }
9 if(C2){
10 S4;
11 }
12 if(C3){
13 S5;
14 }
15 S6;
16 }
Problem 2:
1 void Q2(){
2 if(C1&&C2){
3 S1;
4 while(C3){
5 S2;}
6 }else{
7 if(C4){
8 S3;
9 }else{
10 S4;
11 While(C5){
12 S5;
13 }
14 }
15 }
16 S6;
17 }
Problem 3:
1 void Q1(){
2 for(S1;C1;S2){
3 while(C2){
4 if(C3){
5 S3;
6 }
7 else{
8 if(C4){
9 S4;
10 }
11 }
12 }
13 }
14 S5;
15 }
Problem 4:
1 void Q1(){
2 if(C1){
3 S1;
4 while(C2){
5 if(C3){
6 S2;
7 }
8 else{
9 S3;
10 }
11 }
12 }
13 else{
14 S4;
15 while(C4){
16 S5;
17 while(C5){
18 S6;
19 }
20 }
21 }
22 S7;
23 }