For the case \n statement shown in the Demo Code Example page:
- Both if statement conditions are executed and so are shown in green (covered and executed).
- Both if statements have evaluated as false and so the following functions are shown in red (covered but not executed).
- The else of the second if statement applies and so the following function is executed and shown in green.
- The break of the case statement is shown in 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:
- Halt program execution.
- Open the Program Memory window: Window > Target Memory Views > Program Memory.
- Place a breakpoint at the second if statement of case \n.
- Debug until the program pauses at the breakpoint.
- Step Into once.
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 understand 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.