-
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, S12, S3 and S4 ?
-
- T1, T2, T3
- T2, T4
- T3, T4
- T1, T2, T4
- T1, T2, T3
Correct Option: D
In a given program we take the test cases and apply.
First take T1, if all value equal means
a = b = c = d
So, due to T1, a = b condition satisfied and S1 and S4 executed.
So, from T2 when all a, b, c, d distinct.
S1, S2 not execute, S3 execute.
from T3 when a = b then, S1 execute but c = d so, S2 not execute but S3 and S4 execute but we have no need of T3 because we get all result from above two.
By using T4. If a! = b and c = d
So, S1 not execute and S2 and S4 execute so all of S1, S2, S3, S4 execute and covered by T1, T2 and T4.