google mock with boost::test causes memory leak

1k views Asked by At

I am trying to create unit tests using boost::test and google mock. Adding a call to InitGoogleMock causes boost to signal some memory leaks. I searched for some sort of "DeInitGoogleMock" but didn't find any.

Why does this memory leak come up? How can it be fixed?

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 );
}

Output:

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

Output after uncommenting the InitGoogleMock lines:

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

There are 0 answers