[test] Standalone use with multiple translation units?
Hi all, I am currently using Boost Test for my test code, however it is always an extreme headache trying to get Boost available on the target platforms I'm using. At the moment due to some environment restrictions it is just not possible to use a recent version of Boost, and since the Test library broke backwards compatibility with 1.59, my code will no longer compile on versions earlier than 1.59. So I am looking to see whether I can avoid the need to compile the full Boost, and just pull in the bits that I need. The Boost Test docs say that the library can be used in single-header mode, however this only works when there is one translation unit. Since my tests are spread across dozens of files, I don't think this will work for me. Is there any way to use this single-header mode, and flag one file as the "primary" one, and others as extras, so that you can use single-header mode across multiple translation units? This would remove the need to do battle with getting the Boost libraries installed on various platforms, which would make it much easier and allow me to spend more time on my code, and less time on writing build scripts. Many thanks, Adam.
Adam Nielsen
Hi all,
I am currently using Boost Test for my test code, however it is always an extreme headache trying to get Boost available on the target platforms I'm using. At the moment due to some environment restrictions it is just not possible to use a recent version of Boost, and since the Test library broke backwards compatibility with 1.59, my code will no longer compile on versions earlier than 1.59.
Which specific part?
So I am looking to see whether I can avoid the need to compile the full Boost, and just pull in the bits that I need.
The Boost Test docs say that the library can be used in single-header mode, however this only works when there is one translation unit. Since my tests are spread across dozens of files, I don't think this will work for me.
Is there any way to use this single-header mode, and flag one file as the "primary" one, and others as extras, so that you can use single-header mode across multiple translation units?
This would remove the need to do battle with getting the Boost libraries installed on various platforms, which would make it much easier and allow me to spend more time on my code, and less time on writing build scripts.
This is actually not that difficult it seems. In one translation unit define
BOOST_TEST_MODULE and use inlined header:
#define BOOST_TEST_MODULE single header multiunit test
#include
since the Test library broke backwards compatibility with 1.59, my code will no longer compile on versions earlier than 1.59.
Which specific part?
The boost::unit_test::make_test_case() function got some extra parameters. I guess I could use #ifdefs and have two different versions of the function call, but that does get messy quickly.
This is actually not that difficult it seems. In one translation unit define BOOST_TEST_MODULE and use inlined header:
#define BOOST_TEST_MODULE single header multiunit test #include
in all other translation units just do this:
#include
Oh that looks easy, I will try that! Many thanks, Cheers, Adam.
participants (2)
-
Adam Nielsen
-
Gennadiy Rozental