Next: , Previous: TEST_FAIL, Up: Test Macros


3.2.4 TEST_FP

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

Synopsis

     #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 )

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

Description

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.

Example

     TEST_FP( "float equiv", 33 * 2.2, 36 );