The parameterized class member function based test case

Boost.Test > Components > The Unit Test Framework > Components > The Test Case > The parameterized class member function based test case

# The parameterized class member function based test case

##### Definition

defined in unit_test_suite.hpp

##### Synopsis

    template<class UserTestClass, typename ParamIterator, typename ParameterType>
    class parametrized_class_test_case : public test_case
    {
        ... // Implementation
    };

##### Description

Instances of the class parametrized_class_test_case are created by the framework for the supplied method of the user's test class with the following specification: void (UserTestClass::*fct)( ParameterType ). The parametrized_class_test_case is responsible for the creation and the destroying of the user's test class instance.

##### Construction

To create an instance of the class parameterized_class_test_case use the following macro:

BOOST_PARAM_CLASS_TEST_CASE( test_class_method_pointer, first_parameter, last_parameter ).

The macro's first parameter is the pointer to the member function - body of the test case. The first_parameter and last_parameter are begin and end iterators for the list of parameters accordingly. BOOST_PARAM_CLASS_TEST_CASE creates a new instance of the class parametrized_class_test_case and returns a pointer to the abstract class test_case. In most cases you will use it as an argument to the method test_suite::add(...). Be aware that the parametrized_class_test_case does not store list of parameters internally. The user should make sure that parameters list will not be destroyed until the test case is run. That's why it not recommended to create a parameters list as local variable in init_unit_test_suite. For example, you can place parameters list in file scope.

##### Example:

    class my_complex_test
    {
        void test_assignment( double tolerance )
        {
            ...
        }
    };
    ...
    std::list<double> possible_tolerances;
    ts->add( BOOST_PARAM_CLASS_TEST_CASE( &my_complex_test::test_assignment,
                                          possible_tolerances.begin(),
                                          possible_tolerances.end() ) );