我正在學習有關升壓單元測試,我發現,令人高興的是,它可以檢測內存泄漏,所以我測試它。我創建了以下方法可怕:升壓單元測試不會失敗
int ForTest::Compare(const ForTest item)
{
ForTest* existing_item = this;
char* x=new char[1024];
m_name = std::string(x);
if (existing_item->m_count * existing_item->m_price == item.m_count * item.m_price) return 0;
if (existing_item->m_count * existing_item->m_price > item.m_count * item.m_price) return 1;
return -1;
}
BOOST_AUTO_TEST_CASE(a_test_case)
{
BOOST_TEST_CHECKPOINT("weird...");
ForTest alpha("Pen", 4, 4.3);
ForTest beta;
BOOST_CHECK_EQUAL(alpha.Compare(beta), 1);
}
我明明在這裏創造200個內存泄漏。爲什麼測試者不關心?我的測試通過了大膽的色彩。
我不希望有修改實際的代碼,因爲我在這裏看到:http://www.boost.org/doc/libs/1_35_0/libs/test/example/exec_mon_example.cpp
爲什麼我沒有得到一個錯誤?
哪個平臺,你運行的? Boost執行監視器內存泄漏檢測僅適用於某些平臺。 –
Visual Studio 2010中,窗戶 – Thalia