Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Customizing the module's initialization function

In the shared-library variant, it is impossible to customize the initialization function without customizing the entry point. We have to customize both. In one of the source files, you now have to define your custom entry point and initialization function init_unit_test; next invoke the default test runner unit_test_main manually with init_unit_test as argument. You do not define BOOST_TEST_MODULE in the main file:

In exactly one file

In all other files

#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

// initialization function:
bool init_unit_test()
{
  return true;
}

// entry point:
int main(int argc, char* argv[])
{
  return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
}
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

//
// test cases
//

//
// test cases
//

//
// test cases
//

PrevUpHomeNext