Boost logo

Boost Users :

From: Rozental, Gennadiy (gennadiy.rozental_at_[hidden])
Date: 2004-07-02 14:57:42


> > > void validate(X args) {
> > > if (some tests)
> > > BOOST_ERROR("message");
> > > }
> > > BOOST_AUTO_UNIT_TEST(testfunction) {
> > > // set up arguments
> > > validate(args)
> > > }
[...]
> I think the problem is a think-o on my part.
> In the pseudo-code above, BOOST_ERROR is not executed unless
> "some tests" is true. So if the tests are OK, BOOST_ERROR is
> never hit.
>
> I think the report of 0 (boost) tests being run is therefore
> accurate, though confusing.

It should actually say that 1 test cases being run, but no assertions
executed.
 
> Does that sound right?
>
> Is there a way to signal to boost that you are doing a test,
> without the error?

You have 2 choices.

1. Rewrite your test, so that it looks like:

...
BOOST_CHECK_MESSAGE( some_test, "message" );

2. Or you could write it like this:

....
If(some_test)
    BOOST_ERROR("message")
else
    BOOST_MESSAGE( "no error" );

I prefer first solution usually.

HTH,

Gennadiy


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