From 2441a79c7bf79eebf12e6b10221f70b2d8d11b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 17 Mar 2010 21:58:53 +0100 Subject: [PATCH] unit testing: use const_cast instead of defines --- test/testmemleak.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index a32f48f88..dd8035507 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -18,10 +18,8 @@ -#define private public #include "tokenize.h" #include "checkmemoryleak.h" -#undef private #include "testsuite.h" #include @@ -585,9 +583,10 @@ private: Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); + Token *tokens = const_cast(tokenizer.tokens()); // replace "if ( ! var )" => "if(!var)" - for (Token *tok = tokenizer._tokens; tok; tok = tok->next()) + for (Token *tok = tokens; tok; tok = tok->next()) { if (Token::Match(tok, "if|while ( var )")) { @@ -606,7 +605,7 @@ private: settings._showAll = all; CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, NULL); all = false; - checkMemoryLeak.simplifycode(tokenizer._tokens, all); + checkMemoryLeak.simplifycode(tokens, all); std::ostringstream ret; for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) @@ -721,7 +720,7 @@ private: tokenizer.tokenize(istr, "test.cpp"); // replace "if ( ! var )" => "if(!var)" - for (Token *tok = tokenizer._tokens; tok; tok = tok->next()) + for (Token *tok = const_cast(tokenizer.tokens()); tok; tok = tok->next()) { if (tok->str() == "if_var") {