Quantcast

[test]redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[test]redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar

Boost - Dev mailing list
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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [test]redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar

Boost - Dev mailing list
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



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [test]redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar

Boost - Dev mailing list
Thank you Raffi,

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

That is exactly I expect solution. I look forward to releasse 1.64.0.

Thanks,
Takatoshi Kondo

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...