使用boost :: test的google mock会导致内存泄漏

时间:2016-08-11 08:20:58

标签: c++ boost memory-leaks gmock boost-unit-test-framework

我正在尝试使用boost :: test和google mock创建单元测试。 添加对InitGoogleMock的调用会导致提示发出一些内存泄漏信号。我搜索了一些" DeInitGoogleMock"但没有找到任何。

为什么会出现这种内存泄漏?如何解决?

main.cpp中:

#include <gmock/gmock.h>

#define BOOST_TEST_MODULE my_testt
#include <boost/test/unit_test.hpp>

struct InitGMock {
  InitGMock() {
    ::testing::GTEST_FLAG(throw_on_failure) = true;
    //::testing::InitGoogleMock(&boost::unit_test::framework::master_test_suite().argc,
    //  boost::unit_test::framework::master_test_suite().argv);
  }

  ~InitGMock() { }
};

BOOST_GLOBAL_FIXTURE(InitGMock);

BOOST_AUTO_TEST_CASE( test_case )
{
  BOOST_CHECK( true );
}

输出:

Running 1 test case...
*** No errors detected

取消注释InitGoogleMock行后的输出:

Running 1 test case...
*** No errors detected
Detected memory leaks!
Dumping objects ->
{669} normal block at 0x00B4E700, 48 bytes long.
 Data: <                > 00 E7 B4 00 00 E7 B4 00 00 E7 B4 00 CD CD CD CD
{668} normal block at 0x00B473B0, 28 bytes long.
 Data: <                > 00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD
{667} normal block at 0x00B471B8, 24 bytes long.
 Data: <                > FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00
Object dump complete.

0 个答案:

没有答案