And the answer in this case is no. And
the reason for this is because this code is
unreachable. This is dead code because no matter the
value of j, this condition will always be false because
i will always be 0. And notice that this
is a small example, but another important truth is
that any non-trivial program contains dead or unreachable code,
code that no matter how well we test our system,
we will never be able to exercise. Why is that? Various
reasons. For example, defensive programming or,
for example, developing for future releases.
So there might be pieces of code that are added, but they're
still not activated. They're still not invoked by any other part of
the code because of modifications to the code. There are some
parts that were executed before and in the new version of the
program, they are no longer exercised. They are no longer executable. But
they still remain in the code base. And this is a very,
very normal situation for this reason and many more. And this is
an important concept because this affects
the very meaning of coverage measures. If
there is some unreachable code, we will never be able to reach
100% code coverage. And in fact, if you remember, at the beginning of
the lesson, we discussed this concept and asked you why you think
that, in the industry, the target for coverage is not 100% but less
that that. And that's the answer, to account for the fact that there
are infeasibility problems that I have to take into account when I test
the code, infeasible paths, unexecutable statements, conditions that can never
be true, and so on. So most criteria, if not
all, are affected, and we need to take that into
account when we try to achieve a given coverage target.