Next: TEST_FP_TOL, Previous: TEST_FAIL, Up: Test Macros
test a floating point expression against a value, with a tolerance range
#include <testlib.h> TEST_FP(desc, expr, res ) TEST_FP_LINE(line, desc, expr, res ) TEST_FPABS(desc, expr, res ) TEST_FPABS_LINE(line, desc, expr, res )
- line
- the line number to output
- desc
- a short description of the test being performed
- expr
- a floating point expression to evaluate
- res
- the expected result of the floating point expression
TEST_FP
is called to determine the equivalence of a floating
point expression against an expected result within a tolerance range.
If the relative numeric difference between the two values is less than the
default tolerance of 100.0 * DBL_EPSILON
, they are considered
equivalent. ( DBL_EPSILON
is defined in
/usr/include/float.h). To specify a tolerance,
see TEST_FP_TOL.
TEST_FPABS
is similar, but uses an absolute tolerance check.
TEST_FP( "float equiv", 33 * 2.2, 36 );