Derivation of Justifications

Justifications are assigned by the user to certain counters. For dependent other counters, statements and lines, ctcreport derives the status Justified with the following rules.

Basic rule

A counter or a block of statements is justified, when all possible execution paths leading to this item are justified.

Example: With one justification directly assigned to the false counter in line 22, the else block with all statements and counters is justified, as there is only one, justified path to this block. The statement after the else branch in line 33 is also justified, because the path via the if branch is blocked by the return statement in line 25. Without this return, code in line 33 and later would not be justified.

Details

The basic rule is applied to different kind of code elements, with some special considerations:

Statements
For statements, justification property is derived per block. Statements form a block in this sense if there is nothing with a counter and nothing like a branch or loop end in between. This block is justified if all paths to it are justified, and the execution path to the following code element is justified. The number of statements in this block is counted as justified for statement coverage.
Elements with counters
if decisions, return statements etc., are justified by derivation according to the basic rule. In this case, all their counters are justified and the execution paths originating in these counters (for example, from a false counter of an if statement to the code after the if branch).
There is one exception for loop heads of for and while loops: the execution path from the loop tail or a continue statement to its head is not considered when analyzing all execution paths directing to the loop head.
Lines
Typical code lines containing one statement or element are justified if the element is justified. When the justification state changes in one line, the line gets the status PartiallyJustified.
Remark: Justified and PartiallyJustified lines are both highlighted in blue in the standard HTML report.
MC/DC
Justifications can be assigned directly to true-false-combinations. For each condition, a pair of true-false-combinations is justified if one of the combinations is justified and the other one is tested or justified.
For the MC/DC criterium of a condition, the basic rule idea applies: it is justified, if all possible pairs are justified.
Example: With one direct justification for combination 4, the pairs (1, 4) and (2, 4) are justified, as combination 1 and 2 are tested. The MC/DC criterium for condition b is in consequence also justified, but not the criterium for condition c, as (3, 5) is a possible pair neither tested nor justified.
Conditions
A counter of a condition of a composite decision is justified, if all true-false-combinations with the matching value for this counter are justified.
Decision counters and true-false-combinations
A justification of a true or a false counter of a composite decision leads to justifications of all true-false-combinations with the corresponding value. This is considered as the user's intention. Conversly, if all true-false-combinations with value true or false, respectively, are justified, the corresponding counter of the decision is justified.
Not reachable code
If code cannot be executed, there is no execution path to it, and hence there is never a justification derived for this code. Additionally, unreachable code can prevent the derivation of justifications for other elements: in the following example, this happens for code in line 49 and later.