The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+8 votes
1.3k 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
asked in IS&Software Engineering by Veteran (101k points)
retagged by | 1.3k views

3 Answers

+21 votes
Best answer
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
answered by Boss (11.5k points)
selected by
+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)
answered by Active (2.1k points)
+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

answered by (213 points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

39,529 questions
46,674 answers
139,823 comments
57,593 users