Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2007-02-19 08:37:19


Gennadiy Rozental wrote:
> How about a compromise:
>
> BOOST_CHECK_PERCENT_DIFF
> BOOST_CHECK_RELATIVE_DIFF
> BOOST_CHECK_EPSILON_DIFF
> BOOST_CHECK_ABSOLUTE_DIFF (do we need this one?)

I could live with those. They still say what they do, but I'd like to hear
other opinions.

> So.Would you care to provide a error message body for the non-percent
> based tools?

Well for instance:

BOOST_CHECK_PERCENT_DIFF(x, y, tol);

"Relative difference between x{%1%} and y{%2%} exceeds tol{%3%%}, the actual
difference found was %4%%."

BOOST_CHECK_RELATIVE_DIFF(x, y, tol);

"Relative difference between x{%1%} and y{%2%} exceeds tol{%3%}}, the actual
difference found was %4%."

BOOST_CHECK_EPSILON_DIFF(x, y, tol)

"Relative difference between x{%1%} and y{%2%} exceeds tol{%3%epsilon}, the
actual difference found was %4%epsilon."

BOOST_CHECK_ABSOLUTE_DIFF(x, y, tol)

"Absolute difference between x{%1%} and y{%2%} exceeds tol{%3%}}, the actual
difference found was %4%."

Probably you could figure out a way for them all to use the same code
internally as there's not much variation between them?

Note that compared to your existing messages I've added what the actual
*found* difference was. This is something I've really missed in the
existing messages: in some situations (say with 128-bit long doubles) the
difference can be very small - if you just cut and paste the values into a
calculator to try and work out what the error rate actually was then
truncation of input values leads to a zero result - how many calculators do
you know that do 35-digit precision? At times the only way I could actually
work out what the difference was was either to:

1) Use a pencil and paper.
2) Do it my head (not advised).
3) step through the Boost.Test code to find out.
4) Write my own code to calculate it.

None of which are exactly ideal :-(

If you're wondering why I want to know: it's because sometimes what
constitutes an acceptable rate of error has to be a judgement call, and may
vary from platform to platform. I want the tolerance as low as possible -
to catch regresions - but sometimes that means I set it just slightly too
low for a particular compiler/platform combination. If I could see what the
actual relative difference was then I would know right away whether I had a
real problem, or just a tolerance that was a bit too low.

HTH, John.

PS Thanks for persevering with this, very much appreciated!


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