The Gateway to Computer Science Excellence
+8 votes
2k 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
in IS&Software Engineering by Veteran (105k points)
retagged by | 2k views

3 Answers

+23 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
by Boss (11k 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)
by Active (2.5k points)
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 .
+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

by Junior (579 points)
Answer:

Related questions

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
50,737 questions
57,355 answers
198,482 comments
105,249 users