samsri
samsri

Reputation: 1104

Unable to get correct output

Hi I am preparing for a competitive exam. While solving previous years question I came across this question

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?

(A) T1, T2, T3
(B) T2, T4
(C) T3, T4
(D) T1, T2, T4

Now I'm getting only T2 as answer. But the answer they gave is option D

please help me solve the question

Upvotes: 1

Views: 148

Answers (1)

Reza S
Reza S

Reputation: 9748

You have to write down what each of the test cases cover, and the pick and choose from them:

  1. T1: Only S1 is executed
  2. T2: Only S3 is executed
  3. T3: Only S1 is executed
  4. T4: S2 and S4 are executed

So in order to cover them all you either need T1+T2+T4 OR T2+T3+T4. Since the latter is not an option, you're left with option D.

Hope it makes sense

Upvotes: 4

Related Questions