BOOST_WARN_SMALL( val, tolerance )
BOOST_CHECK_SMALL( val, tolerance )
BOOST_REQUIRE_SMALL( val, tolerance )

These tools are used to check that supplied values is small enough. The "smallness" is defined by absolute value of the tolerance supplied as a second argument. Note that to use these tools you need to include additional header floating_point_comparison.hpp. Use these tools with caution. To compare to values on closeness it's preferable to use BOOST_<level>_CLOSE tools.

The first parameter is the value to check. The second parameter is the tolerance .

Example: test.cpp

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp> BOOST_AUTO_TEST_CASE( test ) { double v = -1.23456e-3; BOOST_CHECK_SMALL( v, 0.000001 ); }

Output:

Running 1 test case...
test.cpp(9): error in "test": absolute value of v{-0.00123456} exceeds 1e-06

*** 1 failure detected in test suite "Master Test Suite"

See Also

BOOST_CHECK_CLOSE, BOOST_CHECK_CLOSE_FRACTION, Floating point comparison algorithms