Is it possible to use BOOST_PARAM_TEST_CASE with automatic registration on boost::test?

前端 未结 6 842
名媛妹妹
名媛妹妹 2021-02-14 03:50

Is it possible to mix up the BOOST_AUTO_TEST_CASE and BOOST_AUTO_TEST_CASE_TEMPLATE macros with the BOOST_PARAM_TEST_CASE in any way? I\'m

6条回答
  •  不知归路
    2021-02-14 04:50

    Starting with Boost version 1.59, this is being handled by data-driven test cases:

    #define BOOST_TEST_MODULE MainTest
    
    #include 
    #include 
    #include 
    
    static const boost::array< int, 4 > DATA{ 1, 3, 4, 5 };
    
    BOOST_DATA_TEST_CASE( Foo, DATA )
    {
        BOOST_TEST( sample % 2 );
    }
    

    This functionality requires C++11 support from compiler and library, and does not work inside a BOOST_AUTO_TEST_SUITE.

    If you have to support both old and new versions of Boost in your source, and / or pre-C++11 compilers, check out And-y's answer.

提交回复
热议问题