Forced Conditions
Test RealTime - User Guide
result * value :
max;
}
return result ;
} /* There are 4*2 basic conditions in this function */
/* Near_color function */
ColorType near_color ( ColorType color )
{
switch ( color )
{
case WHITE :
case LIGHT_GRAY :
return WHITE;
case RED :
case PINK :
case BURGUNDY :
return RED;
/* etc ... */
}
} /* There are at least 5 basic conditions here */
Two branches are enumerated for each condition, and one per case or default.
Forced Conditions
Forced conditions are multiple conditions in which any occurrence of the | | and &&
operators has been replaced in the code with | and & binary operators. Such a
replacement done by the Instrumentor enforces the evaluation of the right operands.
You can use this coverage type after modified conditions have been reached to be
sure that every basic condition has been evaluated. With this coverage type, you can
be sure that only the considered basic condition changed between the two tests.
/* User source code */ /* -
cond=forceevaluation */
if ( ( a && b ) || c ) ...
/* Replaced with the Code Coverage feature with : */
if ( ( a & b ) | c ) ...
/* Note : Operands evaluation results are enforced to one if
different from 0 */
Note This replacement modifies the code semantics. You need to verify that
using this coverage type does not modify the behavior of the software.
int f ( MyStruct *A )
{
if (A && A->value > 0 ) /* the evaluation of A-
>value will cause a program error using
forced conditions if A
pointer
is null */
{
A->value -= 1;
}
}
42