Recently I've upgraded my project to Visual Studio 2013. Thus initializer_list feature is now available. I need to initialize test data in my unit tests. But I am getting memory leaks using nested initialize_lists.
#include <memory>
#include <boost/test/unit_test.hpp>
struct Test_Fixture
{
Test_Fixture()
:test_data({
std::make_shared<std::vector<int>>(std::vector<int>{ 0, 1 }),
std::make_shared<std::vector<int>>(std::vector<int>{ 2, 3, 4 })
}) {}
std::vector<std::shared_ptr<std::vector<int>>> test_data;
};
BOOST_FIXTURE_TEST_CASE( testcase_1, Test_Fixture )
{
BOOST_CHECK(true);
}
Output:
1> Detected memory leaks!
1> Dumping objects ->
1> {1593} normal block at 0x0051A6E8, 8 bytes long.
1> Data: <` C > 60 F6 43 00 00 00 00 00
1> Object dump complete.
Looks like a compiler bug: See here
This feature doesn't like having classes as list items. See here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With