Boost logo

Boost :

Subject: Re: [boost] boost-test, why is there no DOUBLES_EQUAL?
From: Sebastian Nowozin (nowozin_at_[hidden])
Date: 2011-04-05 17:25:33


Hello Grennadiy,

On Tue, Mar 29, 2011 at 6:19 PM, Gennadiy Rozental <rogeeff_at_[hidden]> wrote:

>>    BOOST_CHECK_DOUBLES_EQUAL(first, second, absolute_tolerance);
> Use BOOST_CHECK_SMALL.

This does not do the job, as
     BOOST_CHECK_SMALL(std::fabs(first - second), 1.0e-3)
will be about as useful as
     BOOST_CHECK(std::fabs(first - second) <= 1.0e-3)

It is not useful because in case this check fails I do not get to see
the original values of both 'first' and 'second', but only their
difference.

In my application, first and second are in the range of 0 to 1, but
can in fact be quite close to zero. The qualitative test is correct
if the absolute difference between first and second is small enough,
irrespectively of the absolute value of first. Therefore, I fail to
see why the boost test library provides only BOOST_CHECK_CLOSE and
BOOST_CHECK_SMALL, but no analog to CPPUNIT_ASSERT_DOUBLES_EQUAL.

Thanks,
Sebastian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk