Modified Condition/Decision Coverage (MC/DC)
MC/DC includes all measure points for decision coverage. Additionally, for each atomic condition in a decision, an independence pair of true-false-combinations has to be tested, showing that the condition can independently determine the value of the decision.
Example: The following function contains a decision consisting of four atomic conditions.
int multicondition(int a, int b, int c, int d){ if ((a || b) && (c || d)){ return 1; } else { return 0; } }
It is tested with the input
multicondition(0, 0, 0, 1); // Test I multicondition(0, 0, 1, 0); // Test II multicondition(0, 0, 1, 1); // Test III multicondition(0, 1, 0, 0); // Test IV multicondition(0, 1, 0, 1); // Test V
These tests provide the following coverage. The true-false table is used as reference for the MC/DC pairs.
For every condition in this example, there are two possible independence pairs listed in the
MC/DC block. For condition a
, either pair (1, 7) or (2, 7) have to be
tested.
d
, the pair (4, 6) has been tested. It shows that
d
can independently determine the value of the decision, as only
the value of d
and the value of the decision
switch:4 (F || T) && (F || T) = T
6 (F || T) && (F || F) = F
For the code in line 2, six measure points are taken into account for MC/DC: the true and false evaluation of the whole decision and the MC/DC criterium for each of the four conditions.
- with ctcreport: option
-measures ...,mcdc,...
, - with ctcpost: option
-fmcdc
.