Boost logo

Boost :

Subject: Re: [boost] [test]redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2017-02-13 23:28:02


Le 13/02/2017 à 15:39, Takatoshi Kondo via Boost a écrit :
> Hello,
>
> I'm using Boost.Test.
>
> When I define BOOST_AUTO_TEST_SUITE, I got a compile error
> 'redefinition of
> boost::unit_test::ut_detail::auto_test_unit_registrar' if the all
> following conditions are satisfied:
>
> 1. The test suite names are the same.
> 2. BOOST_AUTO_TEST_SUITE are defined in different files.
> 3. The files are included by one file.
> 4. BOOST_AUTO_TEST_SUITE are defined at the same line number.
>
> For example,
>
> main.cpp
>
> #define BOOST_TEST_MODULE test
> #include <boost/test/unit_test.hpp>
>
> #include "one.ipp"
> #include "two.ipp"
>
>
> one.ipp
>
> BOOST_AUTO_TEST_SUITE(a)
> BOOST_AUTO_TEST_CASE(tc1) {
> }
> BOOST_AUTO_TEST_SUITE_END()
>
>
> two.ipp
>
> BOOST_AUTO_TEST_SUITE(a)
> BOOST_AUTO_TEST_CASE(tc2) {
> }
> BOOST_AUTO_TEST_SUITE_END()
>
> Here is a live demo:
> http://melpon.org/wandbox/permlink/R459VQ6apnQfapyw
>
> If I insert a line the top of two.ipp, no errors are occurred.
>
> http://melpon.org/wandbox/permlink/jPRTstNDVb7agjXl
>
> According to the following document
> http://www.boost.org/doc/libs/1_63_0/libs/test/doc/html/boost_test/tests_organization/test_suite.html#ref_BOOST_AUTO_TEST_SUITE
>
> "The same test suite can be restarted multiple times inside the same
> test file or in a different test files."
>
> The compile error is caused by the following line:
> https://github.com/boostorg/test/blob/develop/include/boost/test/unit_test_suite.hpp#L326
>
> If I replace
> BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ ) \
> with
> BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __COUNTER__ ) \
> , then the error is disappeared.
>
> However, __COUNTER__ is not portable.
>
> I know that I can compile one.ipp and two.ipp separately, but I also
> want to have the option that include them from one file.
>
> Is there any good way to solve the error?
>
> Thanks,
> Takatoshi Kondo

Hi,

Please have a look here:
https://svn.boost.org/trac/boost/ticket/12712

Thanks,
Raffi


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