Boost logo

Boost Users :

From: Sam Partington (Sam.Partington_at_[hidden])
Date: 2003-04-29 05:44:59


Hello,

I've just started using the preprocessor library, for a fairly simple task.
Essentially I have the have a macro called DECLARE_TESTS, which I use like
the following

DECLARE_TESTS(2, (Test1, Test2) )

which expands into the following

void Test1();
void Test2();

suite()
{
    ADDTEST(Test1);
    ADDTEST(Test2);
}

Now the problem: it is inconvenient to have to specify the size of the the
tuple in the first macro. Is there any way to deduce the size?

The macros I'm using are below.

Thanks in advance for any help (positive or otherwise)

Sam

PS Before you suggest using Boost.Test, we have looked at it, and feel that
it is not quite what we're looking for, and I don't want to get into that
discussion! :-)

 #define DECLARE_TESTS(test_count, test_list) \
                BOOST_PP_LIST_FOR_EACH(UNITTESTS_DECLARE_TEST, _,
BOOST_PP_TUPLE_TO_LIST(test_count, test_list)) \
               public: \
                ClassToTest() \
                { \
                 BOOST_PP_LIST_FOR_EACH(UNITTESTS_ADD_TEST, _,
BOOST_PP_TUPLE_TO_LIST(test_count, test_list)) \
                }

 // implementation macros
 #define UNITTESTS_DECLARE_TEST(R, _, name) void name();
 #define UNITTESTS_ADD_TEST(R, _, name) ADDTEST(name)


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