|
Boost : |
From: Jens Seidel (jensseidel_at_[hidden])
Date: 2008-01-15 10:58:07
On Fri, Dec 21, 2007 at 03:11:09PM +0100, Jens Seidel wrote:
> On Fri, Dec 21, 2007 at 02:51:40AM -0500, Gennadiy Rozental wrote:
> > Let's see concrete examples.
>
> Old code was as simple as:
>
> #include <boost/test/unit_test.hpp>
> using boost::unit_test::test_suite;
>
> test_suite* Jacobi_test_suite();
>
> test_suite* init_unit_test_suite(int, char *[])
> {
> Initialize_logging();
> test_suite *test = BOOST_TEST_SUITE("Master test suite");
> test->add(Jacobi_test_suite());
> return test;
> }
>
> > >> > prefer to define main youself and invoke init function you can do it as
> > >> > well
> > >> > with shared library variant.
> > >
> > > And how?
> >
> > See example 9 on
> >
> > http://www.patmedia.net/~rogeeff/html/utf/user-guide/test-organization/manual-nullary-test-case.html
>
> Right. Thanks! Just changing
>
> test_suite* init_unit_test_suite(int, char *[])
> {
> Initialize_logging();
> test_suite *test = BOOST_TEST_SUITE("Master test suite");
> test->add(Jacobi_test_suite());
> return test;
> }
>
> into
>
> bool init_unit_test()
> {
> Initialize_logging();
> boost::unit_test::framework::master_test_suite().add(Jacobi_test_suite());
>
> return true;
> }
>
> int main(int argc, char *argv[])
> {
> return ::boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
> }
>
> works. Please note that one has to read dozens of pages before as this
> is nearly at the end of the documentation.
But it does not work with Boost 1.33.1 in contrast to 1.34.1 as
master_test_suite() returns a const reference.
I switched now to inclusion of boost/test/included/unit_test_framework.hpp
instead of using libraries. Let's see whether it will break soon as well ...
Jens
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk