Boost.Test > Components > The Unit Test Framework > Components > The Test Case > The free function template based test case

# The free function template based test case

##### Definition

defined in test_case_template.hpp

##### Synopsis

    template<typename TestCaseTemplate,typename TestTypesList>
    class tc_template : public test_case
    {
        ... // Implementation
    };

##### Description

This form of test cases is most useful for testing generic template based components/algorithms with different set of template parameters

##### Construction

To create a test case based on your test function use the following macro on file level:

BOOST_META_FUNC_TEST_CASE( free_test_function );

and following macro at the point of test case instantiation

BOOST_FUNC_TEMPLATE_TEST_CASE( free_test_function, typelist ).

BOOST_META_FUNC_TEST_CASE defines a special meta test case class used internally by test case implementation machinery. The only argument is the name of the free function template - body of the test case BOOST_FUNC_TEMPLATE_TEST_CASE cerates a new instance of the meta test case class that corresponds to argument test case and returns a pointer to the base class test_case. In most cases you will use it as an argument to the method test_suite::add(...). The first parameter to macro is the name of the free function template - body of the test case. The second - list of types it need to be instantiated with.

##### Examples

    template<typename Number>
    void free_test_function( Number* = 0 ) {
        BOOST_CHECK_EQUAL( 2, (int const)Number::value );
    }

    BOOST_META_FUNC_TEST_CASE( free_test_function );

    test_suite*
    init_unit_test_suite( int, char* [] ) {
        test_suite* test= BOOST_TEST_SUITE( "Test case template example" );

        typedef boost::mpl::range_c<int,0,10> numbers;
        test->add( BOOST_FUNC_TEMPLATE_TEST_CASE( free_test_function, numbers ) );

        return test;
    }