Boost Users :
From: Ross Boylan (ross_at_[hidden])
Date: 2005-02-01 19:45:27
On Sat, Jan 29, 2005 at 01:52:53PM -0500, Gennadiy Rozental wrote:
> > I prefer the symmetry of
> > BOOST_CHECK_EQUAL(obj.fn(), true)
> > BOOST_CHECK_EQUAL(obj.fn(), false)
> > since, at different points I'm expecting true or false. I know there
> > are alternatives.
> Why not
> BOOST_CHECK( obj.fn() );
> BOOST_CHECK( !obj.fn() );
> I believe it's more natural.
I was probably also influenced by a literal-minded reading of the
useage suggestion "Prefer BOOST_CHECK_EQUAL to BOOST_CHECK"!
As it turns out, I'm lucky I used the BOOST_CHECK_EQUAL form, because
it exposed this bug. The returned value tested as true, but not ==
true. I was using an uninitialized (actually, post-destruction) value
for the bool, and that's what led to the crazy value.
I reported earlier that overwriting the bits in the bool variable did
not change it. That report was mistaken; at least, when I try it now
I am able to stick numeric values in the bool other than 0 or 1.
I know using unitialized or free'd variables is a no-no, but I'm a bit
surprised bool can take on such wacky values.
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