Testing my code I've encountered a thing that I can't interpret. Examining the code coverage with eclemma I've found a header of a for-loop that is highlighted in yellow with the message reading "1 of 2 branches missing".
The code line is as following:
for (int i = maxIdx; i >= 0; i--) {
The body of the loop is highlighted as covered (and is actually executed), as well as the preceding and following statements, and the method works fine under all possible conditions. The headers of other for-loops, as far as I could notice, are highlighted in yellow with the same message only in cases if the body of the loop have never executed.
What is the sense of this message? What branch is missing?
Here is how
forloop of the formis executed:
ForInitis executedForConditionis evaluatedfalse, thenBodyis not executed and execution continues after looptrue, thenBodyis executed,ForUpdateis executed and execution continues from step 2"2 branches" correspond to the above two options for
ForCondition."1 of 2 branches missing" means that happened only one of these options, either first one, or second one.
In absence of complete example that includes body of your loop, hard to answer your additional questions
However given that
Bodyof your loop was executed, possible that there is exit from the loop in theBodybeforeForConditionevaluates tofalse.For example using latest as of today version 2018-12 of Eclipse IDE for Java that comes with EclEmma 3.1.1:
And maybe there is no such exits in your other loops:
This can also explain
and
because of added case when
ForConditionevaluates tofalsebefore execution ofBody: