background image
<< Function Coverage | Block Code Coverage >>
<< Function Coverage | Block Code Coverage >>

Additional Statements

Runtime Analysis
else return 1;
} /* standard output cannot be covered */
/* Divide function */
void divide ( int a, int b, int *c )
{
if ( b == 0 )
{
fprintf ( stderr, "Division by zero\n" );
exit ( 1 );
};
if ( b == 1 )
{
*c = a;
return;
};
*c = a / b;
}
At least two branches are defined per C function.
The input is always enumerated, as is the output if it can be covered. If it cannot, it is
preceded by a terminal instruction involving returns or an exit.
In addition to the terminal instructions provided in the standard definition file, you
can define other terminal instructions using the pragma attol exit_instr.
Additional Statements
Terminal Statements
A C statement is
term nal
if it transfers program control out of sequence (RETURN,
GOTO, BREAK, CONTINUE), or stops the execution (EXIT).
i
By extension, a decision statement (IF or SWITCH) is terminal if all branches are
terminal; that is if the non-empty THEN ... ELSE, CASE, and DEFAULT blocks all
contain terminal statements. An IF statement without an ELSE and a SWITCH
statement without a DEFAULT are never terminal, because their empty blocks
necessarily continue program control in sequence.
Potentially Terminal Statements
The following decision statements are potentially terminal if they contain at least one
statement that transfers program control out of their sequence (RETURN, GOTO,
BREAK, CONTINUE), or that terminates the execution (EXIT):
·
IF without an ELSE
·
SWITCH
·
FOR
·
WHILE or DO ... WHILE
Non-coverable Statements in C
45