7CCSMASE
Tutorial 8 (Week 9)
1. Consider the deceptively simple program below. Consider the three initial values of a, b and c to be the inputs to the program. So the search space for test data generation is a vector of three values . In this exercise we are concerned with branch and target coverage. There are four targets 1,2,3,4 in the program for which we wish to generate test data.
int a,b,c;
if (a>b)
c=1 /* target 1 */ ;
else { c=2;
if (b==c)
/* target 2 */ ;
}
if (c==3)
do something; /* target 3 */ ;
if (b==42)
do something else; /* target 4 */ ;
• Consider the following 3 input vectors i). <1,2,3>, ii). <-1,-1,4> and iii). <24,52,1> and show what output each produces. None of these covers target 1. Which comes closest?
• Explain why it is not possible to cover target 3 in this program. Which input vector or vectors come closest to hitting target 3?
• Which input vectors hit target 4?
• Is it possible to achieve 100% branch coverage? If yes, give the test suite with 100%
coverage. If not, explain why not and construct a test suite that covers all the reachable branches.
Construct a test suite that gives 100% condition coverage; 100% branch coverage; 100% MC/DC.
2. Assume you have a part of a program:
if( (a&&b)||c){ do X;
} else do Y;
3. Calculate the McCabe Number (cyclomatic complexity) for the following graphs: