Boost Test Library is a portable test framework for performing unit testing in c++
Questions tagged [boost-test]
271 questions
3
votes
3 answers
How to cancel "fatal error" detection in BOOST TEST
I get an error: unknown location(0): fatal error in "suite_1_test_1": child has exited; pid: 5817; uid: 0; exit value: 255
Inside suite_1_test_1 I run a program A with execvp() (after fork()), which may be exit with an error code that is not 0. this…

hudac
- 2,584
- 6
- 34
- 57
3
votes
3 answers
Can I use BOOST_CHECK only in unit tests?
Or Can I use it in regular code?
If the answer is "no", then is there C++ library that will provide me with all the macros like CHECK_EQUAL, CHECK_CLOSE, etc.?

Łukasz Lew
- 48,526
- 41
- 139
- 208
3
votes
1 answer
Using boost::phoenix to adapt a BOOST_CHECK macro
During testing when using c++ 11 I have used the following construct:
std::for_each( coll.begin(), coll.end(),
[ &obj, expRes ]( const value_type& val )
{
BOOST_CHECK_EQUAL( expRes, obj.someFunc( val ) );
} );
I am currently…

mark
- 7,381
- 5
- 36
- 61
3
votes
2 answers
Linker chooses "wrong" main with Boost.Test
When using Boost.Test, there is generally no need to define a main() function, since Boost.Test provides one itself.
I recently had to convert my project to use static linking of 3rd party libraries (on VS2010). Naturally, I had to link to…

Adi Shavit
- 16,743
- 5
- 67
- 137
3
votes
2 answers
Int template member function within a template class
Duplicate question of this.
I have a class like this:
template
class foo {
public:
foo(){}
template
void bar (){}
}
If this class is called with:
int main(){
foo m;
m.bar<1>();
}
It gives the…

guinny
- 1,522
- 10
- 19
2
votes
1 answer
Execute test cases manually or individually in the Boost.Test UTF
I'm using Boost.Test for the unit testing of my class in C++. And I already created my test case using BOOST_AUTO_TEST_CASE. But I want to manually execute my test cases in my code. Like for example I have two testcases, and each test case I want to…

domlao
- 15,663
- 34
- 95
- 134
2
votes
1 answer
init_unit_test_suite redefinition error
I am trying to compile an example from boost::test tutorial:
#include
using namespace boost::unit_test;
void test_case1() { /* : */ }
test_suite*
init_unit_test_suite( int argc, char* argv[] )
{
test_suite*…

Anton Frolov
- 291
- 4
- 15
2
votes
1 answer
How to handle Integer Division By Zero exception using Boost.Test library?
I'm writing unit tests using Boost.Test against some old C math library. One of tested functions in known to raise Integer Division By Zero system exception for some specified input. Let's say it's desired behavior and I want to write negative test…

Mickey
- 33
- 6
2
votes
1 answer
Equivalent of CppUnit protectors for boost::test?
I've used both CppUnit and boost::test for C++ unittesting. Generally I prefer boost::test, mainly because the auto-test macros minimise the effort to setup tests. But there's one thing I really miss from CppUnit: the ability to register your own…

timday
- 24,582
- 12
- 83
- 135
2
votes
0 answers
Can I use BOOST_TEST outside of a test case scope?
I wonder whether I may use the Boost.Test testing macros outside of a test case code scope/block. Such as follows:
struct X {
void test() {
BOOST_TEST( false );
}
};
BOOST_AUTO_TEST_CASE( test1 )
{
X x;
x.test();
}
Live demo:…

Daniel Langr
- 22,196
- 3
- 50
- 93
2
votes
1 answer
Boost test case and suite fixtures in manually defined suite tree
Using Boost 1.46.1 on Windows x86, Android TI 2.2
I have defined my own test suite tree, since I need the user to choose order of the tests. although I'm aware the tests should be independent, this is a requirement. The test suite tree was redefined…

Sha
- 152
- 3
- 8
2
votes
1 answer
Does BOOST_DATA_TEST_CASE always require printability of the samples?
I'm trying to get some data-driven test cases running with BOOST_DATA_TEST_CASE and figured out the basics o far.
However, I noticed that the type that is used as sample input MUST be printable:
This will work:
std::vector…

Martin Ba
- 37,187
- 33
- 183
- 337
2
votes
0 answers
CTest and multi-test binaries
I have a Boost.Test based testsuite, where usually a number of tests is combined into one binary.
If I run them separately from CTest, I get an XML file with one entry per binary, which is not detailed enough in the CI output. There is a nice script…

Simon Richter
- 28,572
- 1
- 42
- 64
2
votes
0 answers
operator<< is already implemented but compiler complains that it is not
I'm newbie with C++, and also with Boost Tests. I'm using Visual C++ on Windows 7.
I have implemented these operators on the same test source file where the tests are:
std::ostream& operator<<(std::ostream& os, const std::tuple

VansFannel
- 45,055
- 107
- 359
- 626
2
votes
0 answers
Custom name for BOOST_DATA_TEST_CASE
Using googletest you can name your parameterized tests based on the parameters using the last argument in INSTANTIATE_TEST_SUITE_P.
Now I am using BOOST_DATA_TEST_CASE, and the tests are currently named _0, ..., _N which makes them hard to…

Zitrax
- 19,036
- 20
- 88
- 110