Multicondition Coverage
Multicondition Coverage includes all measure points for decision coverage. Additionally, it measures if all true-false-combinations for the evaluation of the atomic conditions inside the decision have been tested.
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
The multicondition in line 2 can be evaluated in seven different ways, reduced by
short-circuit evaluation. The test cases provide this coverage:
Test cases I, II and III correspond to evaluation alternative 7, hence its counter has value "3". Test IV corresponds to alternative 6 and test V to alternative 4.
For the code in line 2, nine measure points are taken into account for multicondition coverage: the true and false evaluation of the whole decision and the seven evaluation alternatives.
Multicondition instrumentation is also done in assignment statement, if the expression to be
assigned is a boolean expression containing && or || operators, for example:
x = (a || b) && (c || d);
Note: Multicondition
coverage is available as instrumentation mode with ctc
option
-i m
. It is reported - with ctcreport: option
-measures ...,m,...
, - with ctcpost: by default if the instrumentation mode is multicondition.