Method Code Coverage
Test RealTime - User Guide
·
The third branch is the simple block executed at least twice (entry condition true
at least twice, and false at the end).
Two branches are created in a DO/WHILE loop, as the output condition is tested
after the block has been executed:
·
The first branch is the simple block executed exactly once (output condition true
the first time).
·
The second branch is the simple block executed at least twice (output condition
false at least once, then true at the end).
/* myClass::tryFiveTimes method */ /* -
BLOCK=LOGICAL */
int myClass::tryFiveTimes ()
{
int result, i = 0;
/* letsgo ( ) is a function whose return value depends
on the availability of a system resource, for example */
while ( ( ( result = letsgo ( ) ) != 0 ) &&
( ++i < 5 ) );
return result;
} /* 3 logical blocks */
You need to execute the method tryFiveTimes ( ) several times to completely cover
the three logical blocks included in the while loop.
Method Code Coverage
Inputs to Procedures
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.
Procedure Inputs, Outputs and Returns, and Terminal Instructions
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 )
48