?????嵥 15. ??????????е??????????

#define BOOST_TEST_MODULE Regression
#include <boost/test/included/unit_test.hpp>
typedef struct {
int c;
char d;
double e;
bool f;
} Node;
typedef union  {
int c;
char d;
double e;
bool f;
} Node2;
BOOST_AUTO_TEST_SUITE(Structure)
BOOST_AUTO_TEST_CASE(Test1)
{
Node n;
BOOST_CHECK(sizeof(n) < 12);
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(Union)
BOOST_AUTO_TEST_CASE(Test1)
{
Node2 n;
BOOST_CHECK(sizeof(n) == sizeof(double));
}
BOOST_AUTO_TEST_SUITE_END()

?????????? ?嵥 15 ?д?????????

?????嵥 16. ?? –log_level ??????ж?????????

[arpan@tintin] ./a.out --log_level=test_suite
Running 2 test cases...
Entering test suite "Regression"
Entering test suite "Structure"
Entering test case "Test1"
m2.cpp(23): error in "Test1": check sizeof(n) < 12 failed
Leaving test case "Test1"
Leaving test suite "Structure"
Entering test suite "Union"
Entering test case "Test1"
Leaving test case "Test1"
Leaving test suite "Union"
Leaving test suite "Regression"
*** 1 failure detected in test suite "Regression"

??????????????????

????????????????????????? Boost ??????ó??????в?ν??????????????????????? Boost ???????????????????????????????????????????????????????У?????ж?????????????????????Щ????????磬????????????????????e??????????????????????????????????????????????????????????????嵥 17 ????????????????????????????????????? init_unit_test_suite ???????

?????嵥 17. ???????????л???????????????

#define BOOST_TEST_MODULE MasterTestSuite
#include <boost/test/included/unit_test.hpp>
using boost::unit_test;
test_suite*
init_unit_test_suite( int argc?? char* argv[] )
{
test_suite* ts1 = BOOST_TEST_SUITE( "test_suite1" );
ts1->add( BOOST_TEST_CASE( &test_case1 ) );
ts1->add( BOOST_TEST_CASE( &test_case2 ) );
test_suite* ts2 = BOOST_TEST_SUITE( "test_suite2" );
ts2->add( BOOST_TEST_CASE( &test_case3 ) );
ts2->add( BOOST_TEST_CASE( &test_case4 ) );
framework::master_test_suite().add( ts1 );
framework::master_test_suite().add( ts2 );
return 0;
}

???????????????????? ?嵥 17 ?е? ts1????????? BOOST_TEST_SUITE ????????????????????????????????????????????? add ???????????в????????????????????С????????????? BOOST_TEST_CASE ???????????????????? add ??????????????????????С???????????????????????????У?????????????????master_test_suite ???????? boost::unit_test::framework ????????????????????????????????????嵥 18 ?е??????? Boost ???????????????????????????????

?????嵥 18. ??? master_test_suite ????

master_test_suite_t&
master_test_suite()
{
if( !s_frk_impl().m_master_test_suite )
s_frk_impl().m_master_test_suite = new master_test_suite_t;
return *s_frk_impl().m_master_test_suite;
}