|
Boost : |
Subject: Re: [boost] [test] BOOST_TEST - universal testing tool
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2012-11-06 05:55:58
Andrzej Krzemienski wrote
> Hi Gennadiy,
> The new interface looks very attractive. Below I enclose two suggestions
> that are orthogonal (I think) to your changes, but I thought it was a good
> time to suggest them.
>
> 2012/11/4 Gennadiy Rozental <
> rogeeff@
> >
>
>>
>> 2. BOOST_CHECK_CLOSE, BOOST_CHECK_CLOSE_FRACTION, BOOST_CHECK_SMALL
>>
>> We can deal with these by introducing couple special tags:
>>
>> BOOST_TEST(a == 1.5, unit_test::tolerance(1e-6) );
>> BOOST_TEST(a == 0.003, unit_test::percent_tolerance(1e-6) );
>> BOOST_TEST(a, unit_test::small(1e-3) );
>>
>> On a plus side we'll be able to use these in new previously unavailable
>> way:
>> BOOST_TEST(a > 1.1, unit_test::tolerance(1e-6) );
>>
>> This would test that value of a either > 1.1 or within a fraction
>> tolerance
>> of it.
>>
>
> In my job, we are using Boost.Test in a commercial app. We are doing (and
> testing) some basic computations on physical quantities. It turned out
> that
> for around 95% of the checks on floating-point values we need the very
> same
> (percent) tolerance. And it is inconvenient to have to type the same
> constant time and again. It would be nice if there was a way to define (as
> an option) a "default tolerance". With the solution you propose above,
> having to type this tag "unit_test::percent_tolerance" would incur even
> more "syntactic noise" in cases where the tolerance is "obvious" to the
> reader. Here, the concept of default tolerance would be even more useful.
> Although I am not sure if this is doable. But perhaps it is: if I am able
> to configure the framework so that when it sees a check on floating-point
> numbers it assumes we check with tolerance: default one.
>
> What do you think?
it seems easy for you to define your specific macro
#define MY_FP_TEST(E) BOOST_TEST(E, my_tolerance );
and change the my_tolerance as you want.
Vicente
-- View this message in context: http://boost.2283326.n4.nabble.com/test-BOOST-TEST-universal-testing-tool-tp4638062p4638241.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk