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

# The free function based test case

##### Definition

defined in unit_test_suite.hpp

##### Synopsis

    class function_test_case : public test_case
    {
        ... // Implementation
    };

##### Description

Simplest and most widely used form of test cases. Instances of the class function_test_case are created by the framework for the user supplied pointer to free function with the following specification: void (*fct)(). Note void return type. To report a testing results one should use the Test Tools instead of returning result code.

##### Construction

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

BOOST_TEST_CASE( free_function_address ).

BOOST_TEST_CASE creates a new instance of the class function_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 only parameter to above macro is the pointer of free function - body of the test case.

##### Examples

    void test_feature1()
    {
        ...
    }
    ...

    ts->add( BOOST_TEST_CASE( &test_feature1 ) );

_________________________________________________

    #include <boost/test/unit_test.hpp>
    using boost::unit_test::test_suite;

    // most frequently you implement test cases as a free functions
    void free_test_function()
    {
        BOOST_CHECK( 2 == 1 );
    }

    test_suite*
    init_unit_test_suite( int argc, char* argv[] ) {
        test_suite* test= BOOST_TEST_SUITE( "Example" );

        test->add( BOOST_TEST_CASE( &free_test_function )

        return test;
    }