
Andrey Torba wrote:
How can i check basic exception safety without detecting memory leaks? Windows version says that the code below isn't exception safe, but linux version says nothing.
#define BOOST_TEST_MAIN #include
#include #include using namespace boost::itest; // Boost #include
template
void algo(boost::shared_ptr<T1> x, boost::shared_ptr<T2> y) { } typedef mock_object<> Mock; typedef boost::shared_ptr<Mock> SharedMock;
BOOST_TEST_EXCEPTION_SAFETY( TestCase1 ) { algo(SharedMock( new Mock() ), // memory leak in case of second Mock throws exception SharedMock( new Mock() )); }
This may or may not work depending on the order that the compiler does things. Most likely, on windows, the compiler is creating the two new Mocks and then passing them to the shared_ptr constructors. On Linux, it's probably passing each new Mock to shared_ptr as soon as it's constructed. In Christ, Steven Watanabe