From 0a6a0ae46e61b6e767e667bb9cb9ca92200b9c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 13 Mar 2009 19:52:01 +0100 Subject: [PATCH] TestMemleak: added two testcases for checking for leaks in classes --- test/testmemleak.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 90ae1f40d..a5e5d7697 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -152,6 +152,8 @@ private: TEST_CASE(class7); TEST_CASE(class8); TEST_CASE(class9); + // TODO TEST_CASE(class10); + // TODO TEST_CASE(class11); TEST_CASE(throw1); TEST_CASE(throw2); @@ -1515,6 +1517,30 @@ private: ASSERT_EQUALS("", errout.str()); } + void class10() + { + check("class A\n" + "{\n" + "public:\n" + " int * p;\n" + " A() { p = new int; }\n" + "};\n", true); + ASSERT_EQUALS("memory leak", errout.str()); + } + + void class11() + { + check("class A\n" + "{\n" + "public:\n" + " int * p;\n" + " A();\n" + "};\n" + "A::A() : p(new int[10])\n" + "{ }", true); + ASSERT_EQUALS("memory leak", errout.str()); + } +