Consider the following function, that computes the logarithm
of an integer N, rounded down to an integer. The function assumes
that N > 0, so its behaviour for other values of
N is irrelevant.
int function log(int N)
% assumes that N > 0.
i := 1;
k := 0;
while i < N do
i := 2*i;
if i < N then
k := k+1;
endwhile;
return k;
- Give a set of test data (values for N)
that constitute a branch coverage test. Show clearly what steps
you take to arrive at these values.
(5 points, 2 pages)
- The program does not behave
correctly if N is a power of 2. Is this error likely
to be discovered by inspection, by a branch coverage test, respectively
by a black box test? Why?
(3 points, 1 page)