????????????????????????飬???????????????????????е?????????????????????????????????е?????????? ?????????????????????? ????????????? ??????????????????????

????2. ???÷?Χ

??????????C??C++?????в????

????3. ????????

????3.1 C++???

????3.1.1??????????Visual C++??Windows??????ó???

????3.1.1.1??????CppUnit1.6.2?棬?????·???x:cppunit-1.6.2??

?????????????????ò??????????????????????????·??x:cppunit-1.6.2include??????????????·??x:cppunit-1.6.2lib??

????????DEBUG????????滷????

??????????????????????????testrunnercd.lib?????в??????????????????cppunitcd.lib???????????

???????????Add-ins???????x:cppunit-1.6.2libTestRunnerDSPlugInD.dll??

??????Project Settings/C++/C++ Language??????RTTI??

????3.1.1.2??????????????

????1?????????????Test??????????????????????硰CMabString?????????????MabString.cpp?????????????????TestMabString.cpp??

????2??????????????????????????????????TestMabString?????

??????????testmabstring.h

#ifndef CPP_UNIT_TestNode_H
#define CPP_UNIT_TestNode_H
//???????????????
#include <cppunit/TestCase.h>
#include <cppunit/extensions/HelperMacros.h>
//??????????????????
#include "mabstring.h"
//????????????????????
class TestMabString : public CppUnit::TestCase
{
??//????????????б?????б???????????в??????????????????
??CPPUNIT_TEST_SUITE( TestMabString );
??CPPUNIT_TEST( FindByName );
??CPPUNIT_TEST_SUITE_END();

??protected:
??//
??CMabString m_MabStr;
??public:
????//?????????????????????
????void setUp ();
????//????????
????void tearDown();
??protected:
????//????????
????void FindByName (void);
};

#endif

???????testmabstring.cpp

#include "TestMabString.h"
#include "iostream.h"
#include "strstrea.h"

//?????????

CPPUNIT_TEST_SUITE_REGISTRATION( TestMabString );

//???????????

void TestMabString::FindByName ()
{
??//?????????????в???
??//normal test
??//?????????????????в???
??//extra test??
??//???????????в???
??//exception test??

??bool bRet=false;
??try{
????//put the exception code here...
??}
??//catch(CXXX& e)
??catch(...)
??{
????bRet=true;
??}
??CPPUNIT_ASSERT(bRet);
??//????????????????е???????????е?·????????CMabString???CString
??//?????????????????????CMabString?е?Find?????????CString?е?Find??????//???????????????
??//??????????в??ò????·????
??//other test?? see the ...
}

void TestMabString::setUp ()
{
??//????????????????
??m_pNode=new Node();
}

void TestMabString::tearDown()
{
??//???????????
??if(m_pNode)
????delete m_pNode;
}