For the case '\n'
statement shown:
if
statement
conditions are executed and so shown as green (covered and executed).if
statements
have evaluated as false and so the following functions are shown as red (covered but
not executed).else
of the
second if
statement applies and so the following function is
executed and shown as green.break
of the
case
statement is shown as yellow or partially covered (covered
but partially executed) which seems unexpected as both if
statements have executed. To understand what is going on with partial coverage it is
useful to view the Program Memory window.To see the view, shown in the image above:
if
statement of case '\n'
.In the Program Memory window, you can see the instructions for the
else
clause and break
statement. The compiler has
combined the jump back from the function call and the jump out of the
case
loop into one jump, which associates the
break
statement with the loop. Therefore it appears yellow since
the if
statement condition for true was never executed.
As you can see, viewing Program Memory can help you understanding why a line is partially covered (yellow). In general partially-covered lines can be minimized by writing tests to remove red lines (covered by not executed). Then the remaining yellow lines can be examined in assembly in the Program Memory window.