Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(name, var, types) declares a test case name parameterized by a single template argument var that is evaluated for each type in types. This allows you to write a test case that exercises an invariant across a collection of types. The macro expands into one test case for each type in types, with the template argument var assigned to each type. The types argument must be a Boost.MPL type list and must be defined as a typedef.

#include <boost/mpl/list.hpp>
#include <limits>

typedef boost::mpl::list<
    unsigned char, unsigned short,
    unsigned int,
    unsigned long, unsigned long long> unsigned_types;

BOOST_AUTO_TEST_CASE_TEMPLATE(not_is_signed_for_unsigned_types, T, unsigned_types)
{
    BOOST_REQUIRE(!std::numeric_limits<T>::is_signed);
}

Example Source Code

PrevUpHomeNext