For the program given below: (a) Draw the Control Flow Graph (CFG) (b) Find its
ID: 3827215 • Letter: F
Question
For the program given below: (a) Draw the Control Flow Graph (CFG) (b) Find its Cyclomatic Complexity (CC). (c) How many test cases are required for each of: 1- Statement testing 2- Branch testing 3- Path testing. 4- Exhaustive testing assuming that the maximum number of records is 5. (Justify your answers). (d) Give an example set for test cases of the branch testing. Program Q4 A = 0; B = 0; Read new_rec; {read a new record (X, Y)} Repeat While A > = 0 OR B > = 0 Do If (A 0 Then Print A, X Else Print B, Y Endif Read new_rec; End.Explanation / Answer
part d:
Branch testing is basically a methodology which demonstrate each one of the possible branch from each set of decision point. So that we can reach to all decision point.
Example:
In case of IF statement there are two case that is associated with it, one is true value and another is false value. We need to check each test cases i.e true value and false value both.
So we can say there would two test cases here
i) One to evaluate or validate the true branch
ii) One to evaluate or validate the false branch.
We need to test for these 2, otherwise we test for only true case, the code won't be reachable for false case vie-versa.