??? Boost ?????????
???????????? ???????[ 2013/9/3 10:07:46 ] ????????
??????? BOOST_TEST_CASE ?????????????????????????????????? ?嵥 17 ?У?test_case1??test_case2 ???? void ??????????????????????????д???????????Boost ?????????????Щ????棻????? BOOST_TEST_SUITE ???????????????μ? boost::unit_test::test_suite(<test suite name>)??
???????
???????????????????????test fixture?????????в???????????????????????????????????嵥 19 ????????????????
?????嵥 19. ?????? Boost ???
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
#include <iostream>
struct F {
F() : i( 0 ) { std::cout << "setup" << std::endl; }
~F() { std::cout << "teardown" << std::endl; }
int i;
};
BOOST_AUTO_TEST_SUITE( test )
BOOST_FIXTURE_TEST_CASE( test_case1?? F )
{
BOOST_CHECK( i == 1 );
++i;
}
BOOST_AUTO_TEST_SUITE_END()
?????嵥 20 ???????????
?????嵥 20. Boost ????????
[arpan@tintin] ./a.out
Running 1 test case...
setup
fix.cpp(16): error in "test_case1": check i == 1 failed
teardown
*** 1 failure detected in test suite "example"
??????δ????????? BOOST_AUTO_TEST_CASE ????????? BOOST_FIXTURE_TEST_CASE????????????????????????????? constructor ?? destructor ??????б???????ú??????????????? Boost ???? unit_test_suite.hpp ?????????????? ?嵥 21????
?????嵥 21. ???? unit_test_suite.hpp ?е? Boost ???????
#define BOOST_FIXTURE_TEST_CASE( test_name?? F ) /
struct test_name : public F { void test_method(); }; /
/
static void BOOST_AUTO_TC_INVOKER( test_name )() /
{ /
test_name t; /
t.test_method(); /
} /
/
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; /
/
BOOST_AUTO_TU_REGISTRAR( test_name )( /
boost::unit_test::make_test_case( /
&BOOST_AUTO_TC_INVOKER( test_name )?? #test_name )?? /
boost::unit_test::ut_detail::auto_tc_exp_fail< /
BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); /
/
void test_name::test_method() /
???????????Boost ?? struct F ????????????????? ?嵥 19??????????????????????? C++ ???????й?????????п????????? struct ???????????????????????????????? ?嵥 19 ????????? i ????????? F ????????? t???? ?嵥 20???????????????п?????м?????????????????????????????????????????????????? ?嵥 22 ?????????????У?????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11