Boost logo

Boost Users :

From: Ross Boylan (ross_at_[hidden])
Date: 2005-01-29 12:40:52


On Sat, Jan 29, 2005 at 10:55:23AM -0500, Gennadiy Rozental wrote:
> > std::cout << obj.fn()
> > gives me "76" and
> > BOOST_CHECK_EQUAL(obj.fn), true)
> > fails, with the message
> [...]
> > Any suggestions?
>
> I do not know what is going on with your bool. But I would suggest using
> BOOST_CHECK tool instead for checking result of a function returning bool.
> In this case it wouldn't matter if true is 1234 in fact.
>
> Gennadiy
>
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.

Originally I thought this problem might have something to do with the
particulars of BOOST_CHECK_EQUAL, but it seems not to. For example,
cout << obj.fn()
returns 76 outside of the BOOST_CHECK_EQUAL context, and I also see
(using gdb) 76 as the value for the instance variable that is the
source of the data being returned. My inspection of the source code,
as well as the type info given interactively by gdb, shows that
everything involved is boolean.

Conceivably something, somewhere in the boost headers has something to
do with this. Unfortunately, my efforts to replicate with a simple
case have so far been fruitless.

I found nothing relevant on the gcc bug list, and the word "bool"
doesn't even appear in the changelog.

Ross


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