最近我将项目升级到Visual Studio 2013.因此,initializer_list功能现已可用。我需要在单元测试中初始化测试数据。但是我使用嵌套的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);
}
输出:
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.