Boost logo

Boost Users :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2008-03-11 15:09:49


Stephen Torri <torrisa <at> auburn.edu> writes:

>
> Why in the heck did the boost unit test framework change to remove main?

Shared lib version of Boost.Test does not include main for portability reasons.
You can search for very long discussion on this topic in the mailing list.

> Why does the documentation not reflect this? Why are the example
> describing the old behavior? How am I now suppose to use the Boost unit
> test framework?

Enforce linking with static library in your command line.

 
> The following program will NOT compile because of the change in 1.34.1
> since the 1.33:
>
> /* test_grnn.cpp
>
> #include <boost/test/unit_test.hpp>
>
> using namespace boost::unit_test_framework;
>
> void test_distance_squared ()
> {
> // do work
> }
>
> test_suite*
> init_unit_test_suite ( int, char** )
> {
> test_suite* test = BOOST_TEST_SUITE ("GRNN test suite");
>
> // Allow GRNN to allocate our memory at any location
> test->add ( BOOST_TEST_CASE ( &test_distance_squared ) );
>
> return test;
> }

Alternatively you can write above test module as:

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE GRNN test suite

BOOST_AUTO_TEST_CASE( test_distance_squared )
{
 ....
}

and it will work with shared lib. Remove define BOOST_TEST_DYN_LINK and it
will work with static lib as well.

Gennadiy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net