Program P1
1) integer A, B;
2) input (A);
3) while (A > 0)
4) {
5) B = 1;
6) if (A < 10)
7) B = 0;
8) if (A < 20 or A > 25)
9) B = A * B;
10) else
11) B = A + B;
12) output (A, B);
13) input (A);
14) }
15) output (“Program ends.”);
16) end;
T = {t1=<1>, t2=<33>, t3=<‐1>} or T = {t1=, t2=, t3=}
6. If the decision coverage of T for P1 is less than 100%, what test cases could you add to get 100% decision coverage?
7. What is the condition domain for P1? Express as “line number) condition”.
6. The algorithm can be shown using the below flow chart:
The three traversals are shown for the three values of A (t=-1 in orange, t=1 in green and t=33 in violet)
As we can see, all branches of the flow chart are covered except the right of decision box A>25.
To achieve a 100% decision coverage, we need any values greater than 20 and less than or equal to 25.
Hence, we need to add any of 21, 22, 23, 24, or 25 will give 100% decision coverage.
7. Condition domains for P1 are [in format of "line number) condition"]:
Get Answers For Free
Most questions answered within 1 hours.