From 3bf21680b207df833cfc26cdac83f1a877cbda34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 May 2008 14:01:12 +0000 Subject: [PATCH] testing: Added test for mismatching allocation and deallocation --- tests.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests.cpp b/tests.cpp index 8fb0f9f79..0c76bced5 100644 --- a/tests.cpp +++ b/tests.cpp @@ -681,6 +681,18 @@ static void memleak_in_function() "}\n"; check( CheckMemoryLeak, __LINE__, test20, "[test.cpp:8]: Memory leak: p\n" ); + + const char test21[] = "static char *dmalloc()\n" + "{\n" + " char *p = new char[100];\n" + " return p;\n" + "}\n" + "static void f()\n" + "{\n" + " char *p = dmalloc();\n" + " delete p;\n" + "}\n"; + check( CheckMemoryLeak, __LINE__, test21, "[test.cpp:8]: Mismatching allocation and deallocation: p\n" ); } //---------------------------------------------------------------------------