|
Boost Users : |
Subject: [Boost-users] boost UTF suite namespace collision with user class names
From: Aras Vaichas (aras.vaichas_at_[hidden])
Date: 2012-08-29 09:50:35
Hello,
I've just started using the Boost Unit Test Framework so my problem
may be a bit naive.
I would like to name each test suite after each of my classes.
e.g.
class foo { }
BOOST_AUTO_TEST_SUITE(foo)
{
foo bar;
BOOST_REQUIRE_SOMETHING(bar ... etc ...);
}
This is a problem because the BOOST_AUTO_TEST_SUITE macro expands to:
namespace foo { ... etc ... }
and the compiler gives an error:
'namespace foo{}' redeclared as a different symbol.
I solved the problem by changing the namespace name to something less
likely to collide.
e.g.
#define BOOST_AUTO_TEST_SUITE( suite_name ) \
namespace suite_name ## _boost {
\
BOOST_AUTO_TU_REGISTRAR( suite_name ## _boost )( BOOST_STRINGIZE(
suite_name ) ); \
/**/
Tested and it works.
Comments?
regards,
Aras Vaichas
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