Code Coverage for C++
Inputs identify the C++ methods executed.
/* Vector::getCoord() method */ /* -PROC
*/
int Vector::getCoord ( int index )
{
if ( index >= 0 && index < size ) return Values[index];
else return -1;
}
One branch per C++ method is defined.
These include the standard output (if coverable), all return instructions, and calls to exit(), abort(), or
terminate(), as well as the input.
/* Vector::getCoord() method */ /* -PROC=RET */
int Vector::getCoord ( int index )
{
if ( index >= 0 && index < size ) return Values[index];
else return -1;
}
/* 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 per C++ method are defined. 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 by a call to exit(), abort(), or terminate().
The following decision statements are potentially terminal if they contain at least one statement that transfers program control out of its sequence (RETURN, THROW, GOTO, BREAK, CONTINUE) or that terminates the execution (EXIT).
IF without an ELSE
SWITCH, FOR
WHILE or DO...WHILE
Related Topics