The following Code Coverage color explanations refer to the Simple Code Example page.
No Color - No Coverage Data
Several C constructs do not generate executable code, so they have no highlight. Examples shown include:
- Preprocessor declarations - #include statements
- Variable declarations and initializations
- Comments or commented out code
Green - Covered and Executed
Full coverage for a line occurs when the code on that line is executed completely.
The main() function executes and returns completely, so the beginning, return, and ending lines show full coverage.
The lines of the for loop are all executed to completion except for the break statement, because the if condition is never met. In loops and conditional statements, there are one or more conditions or branches that must all be tested for full coverage.
Functions that are called and complete on a line, such as calcAdd(), are fully covered.
Yellow - Partial Coverage
When code on a line is covered but only partially executed, this is considered partial coverage.
For the simple if statement, the evaluation of a<b is executed but the assignment j=1 is not. Therefore, the line is partially covered. If the statements were on different lines, you will see:
The if-else statement uses binary logic to determine the branch condition. Because of the variable values chosen, the statement is only partially covered because when a has a nonzero value, b will not be evaluated.
Red - Covered but not Executed
As discussed above, in loops and conditional statements there are one or more conditions or branches that must all be tested for full coverage.
The if statement in the for loop is never true, so the following break statement is not executed.
The condition of the if-else statement is evaluated so the else branch is never selected and the following line with calcSub() is not executed.