Opened 5 years ago
Closed 5 years ago
#13170 closed Feature Requests (fixed)
BOOST_AUTO_TEST_CASE_TEMPLATE don't want typedef for list
Reported by: | Owned by: | Raffi Enficiaud | |
---|---|---|---|
Milestone: | Boost 1.67.0 | Component: | test |
Version: | Boost 1.61.0 | Severity: | Cosmetic |
Keywords: | Cc: |
Description
It is possible to test several types using BOOST_AUTO_TEST_CASE_TEMPLATE
typedef boost::mpl::list<int,long,unsigned char> test_types; BOOST_AUTO_TEST_CASE_TEMPLATE( my_test, T, test_types ) { BOOST_TEST( sizeof(T) == (unsigned)4 ); }
But if I don't want to introduce a typedef not used elsewhere, as every individual test would have separate type list:
BOOST_AUTO_TEST_CASE_TEMPLATE( my_test, T, boost::mpl::list< int, long, unsigned char > ) { BOOST_TEST( sizeof(T) == (unsigned)4 ); }
The code above doesn't compile though due to comma in macro. It can be worked around, but workarounds seems to be worse than having extra typedef.
I propose using variadic macro for types parameter and make the example above compiling.
Change History (9)
comment:1 by , 5 years ago
comment:3 by , 5 years ago
Got it working with BOOST_IDENTITY_TYPE
from http://www.boost.org/doc/libs/1_66_0/libs/utility/identity_type/doc/html/index.html:
#include <boost/utility/identity_type.hpp> BOOST_AUTO_TEST_CASE_TEMPLATE( my_test2, T, BOOST_IDENTITY_TYPE((boost::mpl::list< int, long, unsigned char >)) ) { BOOST_TEST( sizeof(T) == (unsigned)4 ); }
I will update the doc accordingly.
comment:5 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 5 years ago
Milestone: | To Be Determined → Boost 1.66.0 |
---|
comment:8 by , 5 years ago
Milestone: | Boost 1.66.0 → Boost 1.67.0 |
---|
comment:9 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Documentation changes on master
does the surrounding with
( )
like:prevent the list from being interpreted by the macro expansion?