Boost Test

2010年3月2日 | 分类: C/C++ | 标签: , ,

对单元测试还很模糊,最近在看Boost Test和Google Test,发现Boost Test可以检测到内存泄漏:

#define BOOST_TEST_MODULE YzLTest
#include <boost/test/unit_test.hpp>
 
BOOST_AUTO_TEST_CASE(Test1)
{
    int* p = new int;
}

运行后就会输出:

Running 1 test case…

*** No errors detected
Detected memory leaks!
Dumping objects ->
{387} normal block at 0x0039B3B0, 4 bytes long.
Data: < > CD CD CD CD
Object dump complete.

跟VS调试器输出的差不多,只是能在单元测试时同时检测内存泄漏,还挺实用。

目前还没有任何评论.