Condition Coverage
Runtime Analysis
int tmp;
case NUMBER :
return node->Value;
case IDENTIFIER :
return current value ( node->Name );
case ASSIGN :
set ( node->Child->Name,
tmp = evaluate ( node->Child->Sibling ) );
return tmp;
case ADD :
return evaluate ( node->Child ) +
evaluate ( node->Child->Sibling );
case SUBTRACT :
return evaluate ( node->Child ) -
evaluate ( node->Child->Sibling );
case MULTIPLY :
return evaluate ( node->Child ) *
evaluate ( node->Child->Sibling );
case DIVIDE :
tmp = evaluate ( node->Child->Sibling );
if ( tmp == 0 ) fatal error ( "Division by zero" );
else return evaluate ( node->Child ) / tmp;
}
} /* There are twelve calls in the evaluate function */
Condition Coverage
When analyzing C source code, Test RealTime can provide the following condition
coverage:
·
Basic Coverage
·
Forced Coverage
Basic Conditions
Conditions are operands of either || or && operators wherever they appear in the
body of a C function. They are also if and ternary expressions, tests for for, while, and
do/while statements even if these expressions do not contain || or && operators.
Two branches are involved in each condition: the sub-condition being true and the
sub-condition being false.
Basic conditions also enable different case or default (which could be implicit) in a
switch to be distinguished even when they invoke the same simple block. A basic
condition is associated with every case and default (written or not).
/* Power_of_10 function */
/* -cond */
int power_of_10 ( int value, int max )
{
int result = value, i;
if ( value == 0 ) return 0;
for ( i = 0; i < 10; i++ )
{
result = max > 0 && ( max / value ) < result ?
41