Boost logo

Boost :

Subject: Re: [boost] [test] BOOST_TEST - universal testing tool
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-11-06 08:06:23


2012/11/6 Gennadiy Rozenal <rogeeff_at_[hidden]>

> Rhys Ulerich <rhys.ulerich <at> gmail.com> writes:
>
> >
> > > BOOST_TEST(a == 0.003, unit_test::percent_tolerance(1e-6) );
> > >
> > > ...
> > >
> > > BOOST_TEST( expr == std::vector<int>{1,2,3,4});
> >
> > Can combine these constructs to perform floating point tests with
> > tolerance on a collection?
> >
> > That is,
> > BOOST_TEST( expr == std::vector<double>{1,2,3,4},
> > unit_test::percent_tolerance(1e-6));
>
> Hmmm... Good point. I'll see if this is possible.
>
> As for "default tolerance", I am afraid it might be a bit surprising if
> plain
> comparison of doubles suddenly will start to use tolerance without user
> say so.
> Unless it is set to zero by default in which case we are back to usual
> semantic.
> Once you set it to something non zero we can probably switch to "close"
> comparison.
>
> What about the scope of the tolerance? Should it be global or per test
> case?
>

>From the perspective of my usage, I guess it could be set per suite, if
this is possible. Per-test would require too much repetition, unless I
could define it in my fixture and have the test framework somehow read it
from the fixture.

Regards,
&rzej


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