From 68bcdb103ca402c0f4d53b9bb717cf3253452905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 9 Dec 2008 07:27:11 +0000 Subject: [PATCH] testmemleak : added a unit test that ensures that the variable id handling works correctly. But it's currently not working, and therefore it's commented out --- testmemleak.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/testmemleak.cpp b/testmemleak.cpp index b2b85926d..034aba815 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -41,7 +41,8 @@ private: // Tokenize.. Tokenizer tokenizer; std::istringstream istr(code); - tokenizer.tokenize( istr, "test.cpp" ); + tokenizer.tokenize( istr, "test.cpp" ); + tokenizer.setVarId(); tokenizer.simplifyTokenList(); // Clear the error buffer.. @@ -127,7 +128,9 @@ private: TEST_CASE( realloc1 ); TEST_CASE( realloc2 ); - TEST_CASE( assign ); + TEST_CASE( assign ); + + // TODO TEST_CASE( varid ); } @@ -1024,6 +1027,21 @@ private: ASSERT_EQUALS( std::string(""), errout.str() ); } + + + void varid() + { + check( "void foo()\n" + "{\n" + " char *p = malloc(100);\n" + " {\n" + " char *p = 0;\n" + " delete p;\n" + " }\n" + " free(p);\n" + "}\n" ); + ASSERT_EQUALS( std::string(""), errout.str() ); + } };