????BOOST_AUTO_TEST_SUITE ?? BOOST_AUTO_TEST_SUITE_END ????????????????????β???????????????????????????????????????Щ?????????? C++ ?????????????????? BOOST_AUTO_TEST_CASE ???????塣?嵥 3 ?????? ?嵥 2 ?д?????????

?????嵥 3. ?嵥 2 ?д???????

[arpan@tintin] ./a.out
Running 2 test cases...
test.cpp(10): error in "test1": check s.size() == 0 failed
*** 1 failure detected in test suite "stringtest"

?????????????????δ???????嵥?е???????????????????? Boost ?????????????????????BOOST_CHECK ?? BOOST_REQUIRE_EQUAL ?? Boost ????????????????????????????????????????

????Boost ???????

????Boost ???????????????????????????????????????????????????????????????? BOOST_WARN??BOOST_CHECK ?? BOOST_REQUIRE??BOOST_CHECK ?? BOOST_REQUIRE ????????????????????????????????????????????У????????????????????????????????????嵥 4 ?????????? C++ ?????????Щ??????????????

?????嵥 4. ??? Boost ????????????????

#define BOOST_TEST_MODULE enumtest
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE (enum-test)
BOOST_AUTO_TEST_CASE (test1)
{
typedef enum {red = 8?? blue?? green = 1?? yellow?? black } color;
color c = green;
BOOST_WARN(sizeof(green) > sizeof(char));
BOOST_CHECK(c == 2);
BOOST_REQUIRE(yellow > red);
BOOST_CHECK(black != 4);
}
BOOST_AUTO_TEST_SUITE_END( )

????????? BOOST_CHECK ??????????? BOOST_REQUIRE ?????????????? BOOST_REQUIRE ???????????????????????????? BOOST_CHECK???嵥 5 ????? ?嵥 4 ?д?????????

?????嵥 5. ??? BOOST_REQUIRE ?? BOOST_CHECK ???????

[arpan@tintin] ./a.out
Running 1 test case...
e2.cpp(11): error in "test1": check c == 2 failed
e2.cpp(12): fatal error in "test1": critical check yellow > red failed
*** 2 failures detected in test suite "enumtest"

????????????????????????????Щ?????????????????????????????2????????ò???????????????????????嵥 6 ????????????

?????嵥 6. ??? Boost ?????麯????????

BOOST_AUTO_TEST(functionTest1)
{
BOOST_REQUIRE(myfunc1(99?? ‘A’?? 6.2) == 12);
myClass o1(“hello world!/n”);
BOOST_REQUIRE(o1.memoryNeeded( ) < 16);
}