...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
It is possible to use the header-only variant of the Unit Test Framework even if the test module has multiple translation units:
BOOST_TEST_MODULE
and include
<boost/test/included/unit_test.hpp>
<boost/test/unit_test.hpp>
An example might be the following:
Translation unit 1, defines BOOST_TEST_MODULE
#define BOOST_TEST_MODULE header-only multiunit test #include <boost/test/included/unit_test.hpp> BOOST_AUTO_TEST_CASE( test1 ) { int i = 1; BOOST_CHECK( i*i == 1 ); }
Translation unit 2, includes <boost/test/unit_test.hpp>
instead of <boost/test/included/unit_test.hpp>
:
#include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE( test2 ) { int i = 1; BOOST_CHECK( i*i == 1 ); }