Next: , Previous: TEST_FP, Up: Test Macros


3.2.5 TEST_FP_TOL

test a floating point expression against a value, within a tolerance range

Synopsis

     #include <testlib.h>
     
     TEST_FP_TOL(desc, expr, res, tol )
     TEST_FP_TOL_LINE(line, desc, expr, res, tol )
     
     TEST_FPABS_TOL(desc, expr, res, tol )
     TEST_FPABS_TOL_LINE(line, desc, expr, res, tol )
     

Parameters

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
tol
the tolerance within which the expr and the res are equivalent.

Description

TEST_FP_TOL is called to determine the equivalence of a floating point expression against an expected result within a specified tolerance range. If the relative numeric difference between the two values is less than the specified tolerance, they are considered equivalent.

TEST_FPABS_TOL is similar, but uses an absolute tolerance check.

Example

     TEST_FP_TOL( "float equiv", 33 * 2.2, 36, 2 );