Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-12-31 22:50:21


Hi.

I'm currently converting the unit tests for the lexical_cast proposition, to
use the Boost unit test framework. It's very good, and it replaces my more
ad-hoc unit test.

There's one thing I'm wondering about. If you get an exception in a test, it
won't show which line caused the exception, only that one has happened
somewhere. In a unit test with 100+ tests, it can be hard to find which one
caused the exception, so I started to litter the test code with
BOOST_CHECKPOINT(), which then shows up at the exception. However, I
realised that even this was just narrowing down the search, and to pinpoint
the error line, one would need one BOOST_CHECKPOINT() for each test line. So
why not automate this?

To do that (without changing the Boost unit test code), I made a few
forwarding macros, like this:

#define BOOST_CHECK_EQUAL_CP(a,b)\

BOOST_CHECKPOINT("BOOST_CHECK_EQUAL("##BOOST_STRINGIZE(a)##","##BOOST_STRING
IZE(b)##")");\
  BOOST_CHECK_EQUAL(a,b)

Maybe one could have this in the library. Or perhaps better, keep the
original macro names, and have a preprocessor symbol determine whether or
not checkpoints should be automatically set, e.g. BOOST_USE_CHECKPOINT.

Comments?

Regards,

Terje


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