Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Minimal Header

A lightweight, minimal version of the testing framework can be obtained by including <boost/test/minimal.hpp>. This header provides only the following macros:

Macro

Meaning

BOOST_CHECK(expression)

If expression is false, the test fails and test execution continues.

BOOST_REQUIRE(expression)

If expression is false, the test fails and test execution terminates.

BOOST_ERROR(message)

Report message, fail the test and continue test execution.

BOOST_FAIL(message)

Report message, fail the test and terminate test execution.

The header supplies an implementation of main that executes a single test case by calling a free function named test_main with the following signature:

int test_main(int argc, char *argv[]);

The arguments argc and argv are passed to test_main from the implementation of main supplied by the test framework. No command-line argument processing is performed by main. A summary report of errors recorded by the test case is printed out after executing the test case. If any exception is thrown by the test case, it is caught by main and treated as an error from the test case.

#include <boost/test/minimal.hpp>

int test_main(int argc, char *argv[])
{
    // test case
}

Example Source Code

PrevUpHomeNext