Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Test] reporting tests with warnings
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-11-18 22:13:47


AMDG

On 11/18/2011 04:27 PM, Richard wrote:
> [Please do not mail me a copy of your followup]
>
> boost-users_at_[hidden] spake the secret code
> <loom.20111117T062902-477_at_[hidden]> thusly:
>
>> Richard <legalize+jeeves <at> mail.xmission.com> writes:
>>> If you keep executing a test case
>>> that's already failed, it is highly likely in C++ that the test
>>> runner will simply crash.
>>
>> This is simply not true.
>
> So if I do something like:
>
> BOOST_CHECK(p);
> BOOST_CHECK(p->accessor());
>
> and p is a null pointer, what good does it do to continue after the
> first failed check? The pointer is null and anything else that is
> checked after that is useless.
>

In this case BOOST_REQUIRE is appropriate,
but not all tests are like this. For
example, with

BOOST_AUTO_TEST_CASE(test_f)
{
    BOOST_CHECK_EQUAL(f(0), 0);
    BOOST_CHECK_EQUAL(f(1), 1);
    BOOST_CHECK_EQUAL(f(2), 1);
    BOOST_CHECK_EQUAL(f(6), 8);
    BOOST_CHECK_EQUAL(f(15), 610);
    BOOST_CHECK_EQUAL(f(47), 2971215073);
}

BOOST_AUTO_TEST_CASE(test_C)
{
    C c1(1, 2);
    C c2(3, 4);
    C c3 = c1 * c2;

    BOOST_CHECK_EQUAL(c3.real(), -5);
    BOOST_CHECK_EQUAL(c3.imag(), 10);
}

It's safe to continue executing even
after a failure and I would want to
continue, especially in the second case.
I can't speak for anyone else, but
the tests that I write tend to look
a lot like this.

In Christ,
Steven Watanabe


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