
AMDG On 11/18/2011 04:27 PM, Richard wrote:
[Please do not mail me a copy of your followup]
boost-users@lists.boost.org spake the secret code
thusly: Richard
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