The examples in the Boost.Test documentation seem to mostly relate to C ++ 03 code.
I wonder if there is still a C ++ 14 / C ++ 17 way for linking BOOST_TEST_CASE to init_unit_test_suite ?
This is what I got from the documentation. I just exchanged boost::bind for lambda. I canโt think about further โmodernizingโ this code. Can anyone?
Introduction:
#include <boost/test/included/unit_test.hpp> #include <memory> // shared ptr using namespace boost::unit_test; using namespace std::literals::string_literals;
Testing Class:
class test_class { public: void test_method1() { BOOST_CHECK( true ); } void test_method2() { BOOST_CHECK( false ); } };
Build Set:
test_suite* init_unit_test_suite( int argc, char* argv[] ) { auto tester = std::make_shared<test_class>(); auto &ts = framework::master_test_suite(); ts.add( BOOST_TEST_CASE( [=](){ tester->test_method1(); } )); ts.add( BOOST_TEST_CASE( [=](){ tester->test_method2(); } )); return nullptr; }
source share