|
Boost Users : |
Subject: Re: [Boost-users] About naming of integer log in base 2
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2010-07-22 06:34:11
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Murilo Adriano
Vasconcelos
Sent: Wednesday, July 21, 2010 10:49 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] About naming of integer log in base 2
> and maybe you need to document some examples of using policies that don't bother to check or at least do so quietly
(your > original idea), just quietly return -1, produce a message and return -1, or message and then throw an exception.
I should have said that there is an example at \boost_1_43_0\libs\math\example\error_policy_example.cpp
and you will also want to provide some Boost.Test style tests too - something like
BOOST_CHECK_EQUAL(ilog2(1), 1); // Some plain values...
...
BOOST_CHECK_EQUAL(ilog2(FFFFFFFF), 1); // Some cases that might cause trouble.
BOOST_CHECK_EQUAL(ilog2(std::numeric_limits<unsigned_int>::max()), 1); // Other cases that might cause trouble.
Cases that really will cause trouble... in this case zero.
BOOST_CHECK_EQUAL(ilog2(0), -1); // default policy is to just return -1 (or whatever you decide for default).
BOOST_CHECK_THROW(ilog2<policy<bad_argument_error<throw_on_error> > > (0)); // policy that throws an exception for
zero.
In the math library, these tests are obscured by using macros to repeat them for many functions and policies, but you
will find many examples to help you.
Setting this up is really mind-numbingly boring but is very well worth it to provide quality assurance for the users -
Boost quality.
It will make passing a review much more likely.
Have fun!
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow_at_[hidden]
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