|
Boost Users : |
Subject: Re: [Boost-users] About naming of integer log in base 2
From: Murilo Adriano Vasconcelos (muriloufg_at_[hidden])
Date: 2010-08-12 20:04:20
Hi Paul,
> > 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.
I have added some tests:
http://svn.boost.org/svn/boost/sandbox/SOC/2010/bits_and_ints/libs/integer/test/ilog2_test.cpp
And examples:
http://svn.boost.org/svn/boost/sandbox/SOC/2010/bits_and_ints/libs/integer/example/ilog2_policy_test.cpp
That can be found in the docs:
http://svn.boost.org/svn/boost/sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/bits_and_ints.html#boost_integer.bits_and_ints.integer_logarithm_base_2__ilog2_function__
>
> Have fun!
>
>
I am having, thank you :)
> Paul
>
> ---
> Paul A. Bristow
> Prizet Farmhouse
> Kendal, UK LA8 8AB
> +44 1539 561830, mobile +44 7714330204
> pbristow_at_[hidden]
>
-- Murilo Adriano Vasconcelos http://murilo.wordpress.com
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