
Steve M. Robbins <steve <at> sumost.ca> writes:
OK. So reading this, I have the following question. Suppose I'm writing a nifty library and distributing the source code. I write unit tests using Boost.Test.
Now I distribute my code -- together with the tests. Someone else builds my code on their system and runs the tests. I have no control over their install of Boost: they might have static libs, shared libs, or both. Can I write my unit tests so that they link and run in all three cases?
choice 1: Write your unit tests using automated registration tools: #define BOOST_TEST_MODULE my tests #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE( free_test_function ) { BOOST_CHECK( true /* test assertion */ ); } Userls of your library will be able to test it using static library or shared library. Later require BOOST_TEST_DYN_LINK to be added to the compilation line. choice 2: Use single-header variant of UTF #define BOOST_TEST_MODULE my tests #include <boost/test/included/unit_test.hpp> BOOST_AUTO_TEST_CASE( free_test_function ) { BOOST_CHECK( true /* test assertion */ ); } You don't care about library at all. Gennadiy