retagged by
6,138 views
11 votes
11 votes

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 by

3 Answers

Best answer
29 votes
29 votes
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
2 votes
2 votes
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.

Answer : (d)
2 votes
2 votes
#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

Answer:

Related questions

4 votes
4 votes
2 answers
2
0 votes
0 votes
2 answers
3
1 votes
1 votes
1 answer
4