我正在学习有关升压单元测试,我发现,令人高兴的是,它可以检测内存泄漏,所以我测试它。我创建了以下方法可怕:升压单元测试不会失败
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