Using BOOST_AUTO_TEST_CASE_TEMPLATE but passing a list of test values too
I want to test a (quite large) variety of user-defined types using Boost.Test.
As a very contrived example, suppose I wanted to check numeric_limits digits for integer types
I'd like to avoid a tediously long list like this
BOOST_CHECK_EQUAL(std::numeric_limits<char>::digits, 8);
BOOST_CHECK_EQUAL(std::numeric_limits<char>::digits, 16);
BOOST_CHECK_EQUAL(std::numeric_limits<char>::digits, 32);
...
and follow the example of
BOOST_AUTO_TEST_CASE_TEMPLATE
but allow a test value to be passed too,
something like this:
typedef boost::mpl::list
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Paul A. Bristow Sent: 02 December 2015 10:56 To: boost@lists.boost.org Subject: [boost] Using BOOST_AUTO_TEST_CASE_TEMPLATE but passing a list of test values too
I want to test a (quite large) variety of user-defined types using Boost.Test.
As a very contrived example, suppose I wanted to check numeric_limits digits for integer types
I'd like to avoid a tediously long list like this
BOOST_CHECK_EQUAL(std::numeric_limits<char>::digits, 8); BOOST_CHECK_EQUAL(std::numeric_limits<char>::digits, 16); BOOST_CHECK_EQUAL(std::numeric_limits<char>::digits, 32); ...
and follow the example of
BOOST_AUTO_TEST_CASE_TEMPLATE
but allow a test value to be passed too,
something like this:
typedef boost::mpl::list
test_types; and a list of test values, perhaps like this
typedef list_c
test_values; (However it would be *far* more useful to be able to test strings and floats and User-defined types too).
BOOST_AUTO_TEST_CASE_TEMPLATE_????(digits_test, T, test_types, test_values) { BOOST_CHECK_EQUAL(std::numeric_limits<T>::digits, test_values); }
Has any Macro Guru produced a BOOST_AUTO_TEST_CASE_TEMPLATE_? that includes a list of test values?
After some discussion with Gennadiy Rozental (Boost.Test author) ,
the answer is that he is working on a dataset system that would permit this (but not imminent).
Two possible workarounds:
1 Gennadiy suggested using
// List of types to test.
typedef boost::mpl::list
participants (1)
-
Paul A. Bristow