|
Boost Users : |
Subject: Re: [Boost-users] First attempt at using Boost::Test is a flop: the program ends with an exception related to std::string but I don't use any
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-05-23 04:29:23
Hi,
> I also hit a limitation of BOOST_CHECK_CLOSE. In testing my code
> to
> check the accuracy of the algorithm for the standard normalized
> normal
> distribution, of zero mean and unit variance, it always failed,
> giving an
> infinite percent accuracy. Changing the distribution to mean of one
> and
> variance of one resulted in the test passing. Clearly the incorrect
> result
> of a failed test was due to a division by zero, and thus
> BOOST_CHECK_CLOSE
> clearly can not compare a double with 0.0, and that strikes me as a
> significant limitation. It is true that for my purposes, simply
> shifting
> the distribution to the right by one meets my needs, I can imagine
> cases in
> which that is not viable. Is there another macro that is specialized
> for
> the case when the expected outcome, for a double, of a given
> calculation is
> zero?
BOOST_CHECK_CLOSE can't work, because it evaluates a difference between
the two values in percent. But no one can answer how many percent
difference are between 0 and 1 (I think infinite is a good guess,
though). What you are searching is BOOST_CHECK_SMALL which checks,
whether a number is smaller than a certain threshold.
Greetings,
Oswin
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net