boost UTF suite namespace collision with user class names
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
Aras Vaichas
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)
Why don't you use test suite name foo_test(s)? Naming test suites the same as the component under test is not a good practice IMO. Gennadiy
Hi Gennadiy, thank you for getting back to me.
On 2 September 2012 04:08, Gennadiy Rozental
Aras Vaichas
writes: 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)
Why don't you use test suite name foo_test(s)?
Because it seemed redundant. My application contains unit tests grouped by unit test suites. Therefore everything in it is already a test, so each suite is named after the class that it tests. I should be able to name it whatever I choose. From a user's point of view, it's just a name for a test suite, there shouldn't be side effects to choosing a name.
Naming test suites the same as the component under test is not a good practice IMO.
Perhaps not, but the API shouldn't dictate policy. Do you agree? It's a simple fix, do you want me to forward a patch? Aras
participants (2)
-
Aras Vaichas
-
Gennadiy Rozental