Simple Code and Coverage Colors

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:

SimpleIf_2Lines.png

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.

© 2020 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.