Boost logo

Boost :

From: Jens Seidel (jensseidel_at_[hidden])
Date: 2007-10-30 16:12:03


On Tue, Oct 30, 2007 at 06:56:36PM +0000, Gennadiy Rozental wrote:
> Jens Seidel <jensseidel <at> users.sf.net> writes:
> > In this case you should probably change the test. To be honest I have
> > the same problem that I need something similar to
> > BOOST_CHECK_EQUAL_COLLECTIONS which checks a range and creates
> > compressed output. I tried using custom predicate support
> >
> (http://www.boost.org/libs/test/doc/components/test_tools/custom_predicate_supp
> ort.html)
> > but it is complicated ...
>
> What problems do you have?

The problem was the not perfect documentation, no (working) example, I
wasn't even sure it is what I need.

> Don;t use the page above.

Can you please explain why you don't update the official documentation
if you even suggest *not* to read docs on http://www.boost.org?

> Try one unser
> http://www.patmedia.net/~rogeeff/html/ and let me know if you still having
> problems (or docs are not clear enough).

Thanks, will do so!
 
> > Using BOOST_CHECK_CLOSE in a loop sounds just wrong to me.
>
> Hmm. What specifically is wrong with it?

I often need to test large data structures such as vectors or matrices.
Using
 for (int i=0; i<n; ++i)
   BOOST_CHECK_CLOSE(x[i], expected[i], 1E-12);
the output misses the failing indices and is too long (multiple lines
instead a single one). If such a test happens multiple times it's a good
idea to move the code into a separate compare(x, expected) function. But
if the test fails it will display this function as location and not the
previous callstack. Not optimal.

I even used sometimes BOOST_REQUIRED_CLOSE in the loop just to reduce
the output if the test failed but missed further tests this way ...

Jens


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