1.4k views

The following program is to be tested for statement coverage:

begin
if (a==b) {S1; exit;}
else if (c==d) {S2;}
else {S3; exit;}
S4;
end

The test cases T1, T2, T3 and T4 given below are expressed in terms of the properties satisfied by the values of variables $a,\:b,\:c$ and $d$. The exact values are not given.

T1: a, b, c and d are all equal

T2: a, b, c and d are all distinct

T3: a = b and c != d

T4: a != b and c = d

Which of the test suites given below ensures coverage of statements S1, S2, S3 and S4?

1. T1, T2, T3
2. T2, T4
3. T3, T4
4. T1, T2, T4
retagged | 1.4k views

T1 covers S1

T2 covers S3

T3 covers S1

T4 covers S2, S4

so inorder to cover all 4 either T1,T2, T4 or  T2, T3 , T4

option D
selected by
T2 is essential because it is the only statement covering S4, eliminate option (c)

S2 can be covered by T4 only

now condition a==b leading to S1 can be satisfied by T1 only.

0
T2 is not covering s4 pls review again it can cover only S3 bcoz exit keyword is there which is used for leaving the main program .
+1 vote
#include <stdio.h>
#include <stdlib.h>
void main(){
int a=2;
int b=3;
int c=4;
int d=4;

if(a==b){
printf("a is equal to b\n");exit;
}
else if(c==d){
printf("b is equal to d\n");exit;
}
else
printf("b is not equal to d\n");exit;

printf("s4 case\n");
}

This is code you can change values appropriately and get the answer.

T1 covers: s1,s4

T2 covers: s3,s4

T3 covers: s1,s4

T1 covers: s2,s4

Ans: D. T1, T2, T3

+1 vote
1
2