Boost logo

Boost :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2007-04-12 07:08:01


Gennadiy Rozental skrev:
> "Thorsten Ottosen" <thorsten.ottosen_at_[hidden]> wrote in message
> news:461CF01A.4010209_at_dezide.com...
>> Hi Gennadiy,
>>
>> When I use macros such as
>>
>> BOOST_CHECK_MESSAGE( !evidence,
>> "update evidence = " <<
>> withEvidenceUpdate << ", evidence = " << *evidence );
>>
>> it annoys me that the second argument is evaluated even when the test
>> should pass.
>>
>> In the case above, evidence is an optional<int>. It would be cool if the
>> construction of the error messsage could be delayed until it was
>> actually needed, to make the above scenario valid.
>>
>> Do you think that is possible?
>
> The problem is that I might need the message even if test passes(to print
> confirmation massages, if log level is set to "all").

I see.

> Why exactly does it bother you?

Because my test crashes :-)

> You could always workaround it with your own macro:
>
> #define MY_CHECK_MSG( expr, MSG ) \
> if( (expr) ) \
> {} \
> else \
> BOOST_CHECK_MSG( false, MSG ) \
> /**/
>

I could do that, but I prefer the library to handle such situations.

Is it not possible to generate the message only when it is needed. For
example, I don't use log level "all".

-Thorsten


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