????????????“BoostUnitTest.cpp”?е??13?и???
????BOOST_CHECK(tmpTested->add(2?? 2) == 3);
??????????????н?????????????????

???????????ν??????????Boost?????????????????
????// ?????2014.10.18 ---------------------------------------------------------------------------
??????????????????????????????????????????????????????£?
1 #include <iostream>
2
3 using namespace std;
4
5 class Tested
6 {
7 public:
8
9     Tested();
10     virtual ~Tested();
11     int add(const int a?? const int b);
12     void testException();
13
14 private:
15
16 };
1 #include "tested.h"
2
3 Tested::Tested()
4 {
5
6 }
7
8 Tested::~Tested()
9 {
10
11 }
12
13 int Tested::add(const int a?? const int b)
14 {
15     return a + b;
16 }
17
18 void Tested::testException()
19 {
20     throw logic_error("my throw");    // ???????????????
21 }
1 #define BOOST_TEST_MODULE Tested_Module                                // ????????????????????????????????????????
2
3 #include "stdafx.h"
4 #include "D:VSProjectBoostUnitTestBoostUnitTestTested ested.h"    // ??????????
5
6 struct Tested_Fixture                                                // ????о?
7 {
8     Tested_Fixture()
9     {
10         BOOST_TEST_MESSAGE("setup fixture");
11         tmpTested = new Tested();
12     }
13     ~Tested_Fixture()
14     {
15         BOOST_TEST_MESSAGE("teardown fixture");
16         delete tmpTested;
17     }
18     Tested * tmpTested;
19 };
20
21 BOOST_FIXTURE_TEST_SUITE(Tested_test?? Tested_Fixture)                // ???????
22
23 BOOST_AUTO_TEST_CASE(Tested_Method_add_Test)                        // ????????
24 {
25      // TODO: Your test code here
26     BOOST_WARN(tmpTested->add(2?? 2) == 4);                            // WARN???????
27     BOOST_CHECK(tmpTested->add(2?? 2) == 4);                            // CHECK???????
28     BOOST_REQUIRE(tmpTested->add(2?? 2) == 4);                        // REQUIRE???????
29
30 }
31
32 BOOST_AUTO_TEST_CASE(Tested_Method_testException_Test)                // ????????
33 {
34     // TODO: Your test code here
35     BOOST_REQUIRE_NO_THROW(tmpTested->testException());                // ??????????????????????
36     BOOST_REQUIRE_THROW(tmpTested->testException()?? logic_error);    // ?????????????logic_error??
37     BOOST_REQUIRE_THROW(tmpTested->testException()?? runtime_error);    // ?????????????runtime_error??
38
39 }
40
41 BOOST_AUTO_TEST_SUITE_END()
???????????????????н?????£?
????35 BOOST_REQUIRE_NO_THROW(tmpTested->testException());              // ????????
????36 BOOST_REQUIRE_THROW(tmpTested->testException()?? logic_error);    // ???????
????37 BOOST_REQUIRE_THROW(tmpTested->testException()?? runtime_error);  // ????????
???????????и??????????????ο?????????