Boost logo

Boost :

Subject: [boost] Using BOOST_AUTO_TEST_CASE_TEMPLATE but passing a list of test values too
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2015-12-02 05:56:14


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<char, int, long> test_types;

and a list of test values, perhaps like this

typedef list_c<int, 8, 32, 64> 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?

Or other suggestions.

Thanks

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk