How do I define my own main()
function when testing with boost?
Boost is using it's own main function, but I'm using a custom memory manager and it needs to be initialized before any memory is allocated, otherwise I'll get errors.
I do not believe you actually need your own main. I think you are much better off with global fixture:
struct AllocatorSetup {
AllocatorSetup() { /* setup your allocator here */ }
~AllocatorSetup() { /* shutdown your allocator/check memory leaks here */ }
};
BOOST_GLOBAL_FIXTURE( AllocatorSetup );
You have to define
BOOST_TEST_NO_MAIN
before the boost includes.
BOOST_TEST_MAIN
is the default. http://www.boost.org/doc/libs/1_36_0/libs/test/doc/html/utf/compilation.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With