CppUnit???????
???????????? ???????[ 2013/11/20 15:42:22 ] ????????
CppUnit??????
????CppUnit???????????????cpp?????ò????????c++д???unit?“???”??????????
??????ò???????java?汾??????junit??
??????CppUnit??
????CppUnit?淶??????????Щ?????Щ????????????????CppUnit????????????У?
?????????????????????????“????????????????????????”??
????CppUnit???????????????????д??????????????
????????????????????????????????
CppUnit?????????????????????л???????
????????????????
??????????????????????????????????ü??????????????????????????????????????????CppUnit???????????????
?????????????????????????С?
??????????????????????????????鷢???????????????????????????仯/???????????????????????????е????????????????????????????????????????????bug???????????????????????????????????л?顣
??????????????????????????????飩????????????????????????????????????
CppUnit???????
{
public:
CppUnit_TEST_SUITE(TestBSTR);
CppUnit_TEST(test_allocString);
CppUnit_TEST(test_allocStringWithLen);
CppUnit_TEST(test_allocChinese);
CppUnit_TEST_SUITE_END();
public:
void test_allocString()
{
BSTR p;
WCHAR szHello[] = L"Hello?? world!";
p = SysAllocString(szHello);
CppUnit_ASSERT( wcscmp(p?? szHello) == 0 );
CppUnit_ASSERT( SysStringLen(p) == wcslen(szHello) );
SysReAllocString(&p?? szHello);
CppUnit_ASSERT( wcscmp(p?? szHello) == 0 );
SysFreeString(p);
}
void test_allocStringWithLen()
{
BSTR p;
p = SysAllocStringLen(L"ABCDEFGH"?? 4);
CppUnit_ASSERT( wcscmp(p?? L"ABCD") == 0 );
SysReAllocStringLen(&p?? L"XYZ"?? 2);
CppUnit_ASSERT( wcscmp(p?? L"XY") == 0 );
CppUnit_ASSERT( SysStringLen(p) == 2 );
SysFreeString(p);
SysAllocString(L"Memory leak checker");
}
void test_allocChinese()
{
BSTR p = SysAllocString(L"????!");
CppUnit_ASSERT( SysStringLen(p) == 3 );
CppUnit_ASSERT( wcscmp(p?? L"????!") == 0 );
SysFreeString(p);
}
};
CppUnit_TEST_SUITE_REGISTRATION(TestBSTR);
// ???CppUnit_TEST_SUITE_REGISTRATION?????????????? ??
int main()
{
TestApp app;
return 0;
}
????TestApp???????д???????CppUnit?????main??????????£?
{
CppUnit_NS::Test *suite = CppUnit_NS::TestFactoryRegistry::getRegistry().makeTest();
CppUnit_NS::TextUi::TestRunner runner;
runner.addTest( suite );
CppUnit_NS::Outputter* outputter;
outputter = new CppUnit_NS::CompilerOutputter(&runner.result()?? std::cerr);
runner.setOutputter(outputter);
return runner.run();
}
???·???
??????????????????
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