Next: , Previous: TEST_FP_TOL, Up: Test Macros


3.2.6 TEST_RUN_FP

Execute a statement, then test a floating point expression against a value, within a tolerance range.

Synopsis

     #include <testlib.h>
     
     TEST_RUN_FP(desc, stmt, expr, res )
     TEST_RUN_FP_LINE(line, desc, stmt, expr, res )

Parameters

line
the line number to output
desc
a short description of the test being performed
stmt
a statement to be executed, independent of the expression. the statement may be arbitrarily complex.
expr
a floating point expression to evaluate
res
the expected result of the floating point expression

Description

TEST_RUN_FP is called to determine the equivalence of a floating point expression against an expected result within a specified tolerance range. If the 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_RUN_FP_TOL.

Example

TEST_RUN_FP( "float equiv", foo(&x), 33 * x, 36 );