GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 44

Statement-coverage test suite

Engineering Mathematics & Other Topics · Software Engineering · Full GATE CSE 2010 paper

GATE 2010, Q44 2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Software Engineering

Question 44, GATE 2010: Find a test suite covering statements S1,S2,S3,S4 in:
begin
 if(a==b) { S1; exit; }
 else if(c==d) { S2; }
 else { S3; exit; }
 S4;
end
Available test properties: T1: a,b,c,d all equal; T2: all distinct; T3: a=b and c≠d; T4: a≠b and c=d.
Options: (A) T1,T2,T3; (B) T2,T4; (C) T3,T4; (D) T1,T2,T4.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

T1 and T3 both take a==b, execute S1, then exit. T2 takes a!=b and c!=d, executes S3, then exits. T4 takes a!=b and c==d, executes S2 and then S4. Full statement coverage therefore needs T2, T4 and either T1 or T3. Of the offered suites only T1,T2,T4 meets this condition, option D.

The crucial control-flow feature is exit: neither the S1 branch nor the S3 branch reaches S4. Only T4 covers S2 and S4 together. T2 is indispensable for S3, and one of T1/T3 is indispensable for S1. Thus three tests suffice and two cannot cover all three mutually exclusive branch outcomes.

Original paper, page 11