Microsoft Word - A08se4367cf v4.docx
SE 4367, Software Testing
Homework #8, Control Flow Coverage
For the following program P1 written in pseudo-code, given the test set TX:
T = {t1 = <4, 2>, t2 = <90, 0>, t3 = <56, 1>}
a) What is the statement coverage of P1 for TX?
) What is the decision coverage of P1 for TX?
c) What is the condition coverage of P1 for TX?
d) Provide an adequate test set TA with respect to statement coverage for P1.
e) Provide an adequate test set TA with respect to decision coverage for P1.
Program P1
1) integer X, Y, Z;
2) input (X, Y);
3) if ((X≥0 AND X≤100) AND (Y>0 AND Y<4))
4) {
XXXXXXXXXXZ = -1;
6) if (X < 60)
7) {
XXXXXXXXXXZ = 0;
XXXXXXXXXXif (X > 80 AND Y == 1)
XXXXXXXXXXZ = 59;
XXXXXXXXXXZ = Z + 3;
12) }
XXXXXXXXXXelse
!(X<60)
14) {
XXXXXXXXXXZ = 61;
XXXXXXXXXXif (Y > 2)
XXXXXXXXXXZ = 99;
XXXXXXXXXXelse
!(Y>2)
XXXXXXXXXXZ = 62;
20) }
XXXXXXXXXXoutput (X,Y,Z);
22) }
23) else
not legal inputs
XXXXXXXXXXoutput (“ERROR *** Illegal inputs.”);
25) output (“Program ends.”);
26) end;
For the following program P2 written in pseudo-code, given the test set TY:
TY = {t1 = <-1, 2>, t2 = <7, 0>, t3 = <6, 1>}
f) What is the statement coverage of P2 for TY?
g) What is the decision coverage of P2 for TY?
h) What is the condition coverage of P2 for TY?
i) Provide an adequate test set TB with respect to statement coverage for P2.
j) Provide an adequate test set TB with respect to decision coverage for P2.
Program P2
1) integer X, Y, Z;
2) input (X, Y);
3) if (X<0 or X>8 or Y<1 or Y>3)
4) output (“ERROR *** Illegal inputs.”);
5) else
legal inputs
6) {
XXXXXXXXXXZ = 0;
XXXXXXXXXXif (X < 5)
9) {
XXXXXXXXXXZ = X + Y;
XXXXXXXXXXif (Y == 1)
XXXXXXXXXXZ = X ^ 2;
13) }
XXXXXXXXXXelse
!(X<5)
15) {
XXXXXXXXXXZ = Z – X;
XXXXXXXXXXif (Y == 0)
XXXXXXXXXXZ = Z * Z;
XXXXXXXXXXelse
!(Y==0)
XXXXXXXXXXZ = Z + X;
XXXXXXXXXXZ = Z + 1;
22) }
XXXXXXXXXXoutput (X,Y,Z);
24) }
25) output (“Program ends.”);
26) end;
Grading Ru
ic
Parts are worth 10 points each.
Each coverage part
5 points for numerator and 5 for denominator if in ratio (fraction) form
Coverage can be either un-simplified ratios (fractions), decimal numbers [0,1], or
percentages
if expressed as a decimal, two places is sufficient
if expressed as a percentage, to the nearest percent is sufficient
If a decimal or percentage answer for the coverage is provided and wrong, but the
work is shown with a co
ect numerator and an inco
ect denominator, only take 5
points off. (Inco
ect numerator, -10 points)
For each test adequacy part, any uncovered element means the answer is wrong, -10
points
For each test adequacy part, any extra elements added to the adequate test set (not
a minimal test set), -5 points