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: Oleksandr Guteniev <gutenev@…> 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 Raffi Enficiaud, 5 years ago

does the surrounding with ( ) like:

BOOST_AUTO_TEST_CASE_TEMPLATE( 
   my_test, 
   T,
   (boost::mpl::list<
     int,
     long,
     unsigned char
   >) )

prevent the list from being interpreted by the macro expansion?

comment:2 by Raffi Enficiaud, 5 years ago

Kind reminder

comment:3 by Raffi Enficiaud, 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:4 by Raffi Enficiaud, 5 years ago

On next

comment:5 by Raffi Enficiaud, 5 years ago

Owner: changed from Gennadiy Rozental to Raffi Enficiaud
Status: newassigned

comment:6 by Raffi Enficiaud, 5 years ago

On develop

comment:7 by Raffi Enficiaud, 5 years ago

Milestone: To Be DeterminedBoost 1.66.0

comment:8 by Raffi Enficiaud, 5 years ago

Milestone: Boost 1.66.0Boost 1.67.0

comment:9 by Raffi Enficiaud, 5 years ago

Resolution: fixed
Status: assignedclosed

Documentation changes on master

Note: See TracTickets for help on using tickets.