0
代碼片段的相關部分。上面的代碼片段導致在退出時在Win VC 8編譯器中生成以下錯誤。在斷言器中傳遞斷言可以修復崩潰。這個錯誤只在窗口中觀察到,並且在linux中可以正常工作。斷言失敗時CPPUNIT_ASSERT_MESSAGE在析構函數中崩潰
class BasicMathTest: public TestFixture
{
CPPUNIT_TEST_SUITE(BasicMathTest);
CPPUNIT_TEST(testAdd);
CPPUNIT_TEST(testMultiply);
CPPUNIT_TEST(testDivide);
CPPUNIT_TEST_SUITE_END();
class A
{
public:
~A()
{
CPPUNIT_ASSERT_MESSAGE("BasicMath::Addition", 0);
}
};
A ob;
public:
virtual void setUp(void);
virtual void tearDown(void);
void testAdd(void);
void testMultiply(void);
void testDivide(void);
private:
BasicMath *obj;
};
int main()
{
TestRunner testrunner;
Test *tests = TestFactoryRegistry::getRegistry().makeTest();
testrunner.addTest(tests);
testrunner.run(m_testResult);
m_outputter->write();
return !m_collector.wasSuccessful();
}