|
Boost : |
Subject: Re: [boost] [multiprecision] Are these types suitable as numeric types for unit tests?
From: John Maddock (john_at_[hidden])
Date: 2013-06-08 04:39:39
> I'm writing new numeric types, and my unit tests use MPL lists of numeric
> types. I usually use stuff like int, unsigned, and double, but now I'm
> adding cpp_int and cpp_dec_float_50. Those types were OK when I was just
> doing type equalities and sizeof checks. Now I'm doing tests that use
> objects of those types and I'm getting problems.
>
> //====
> typedef boost::mpl::list<int, unsigned, cpp_int> test_integer_types;
> typedef boost::mpl::list<double, cpp_dec_float_50> test_floating_types;
> I'm getting warnings about integer overflow. The problem is at Line 59 of
> boost/test/tools/detail/print_helper.hpp. It sets an output stream's
> precision based on the digits given by std::numeric_limits.
That's harmless but annoying: it's because
std::numeric_limits<cpp_int>::digits is INT_MAX. The stream precision isn't
ever used by integer types anyway...
> This time it's an error, at Line 59 of
> boost/test/tools/floating_point_comparison.hpp. There no (close enough)
> matching function for "fpt_abs" from some
> "boost::multiprecision::detail::expression<..." type. (It was truncated
> by the display. I don't know how to get a clean print-out of errors from
> Code::Blocks.) I'm guessing the expression template setup is screwing
> things up.
Yes, it's because Boost.Test can't be used with expression template enabled
types. It's a known issue, and I've added a patch for this:
https://svn.boost.org/trac/boost/ticket/8272, but Genediiy seems to be MIA
at present :-(
Do you particularly want to test with expression-template enabled types (I
reaslise there are cases when you do)? If not then you could use
multiprecision types that have expression templates turned off and that
should fix things.
HTH, John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk