diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 4b945793f09..ad5a3575974 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -57,10 +57,7 @@ class TestAutoVariables : public TestFixture { tokenizer.simplifyTokenList2(); const std::string str2(tokenizer.tokens()->stringifyList(0,true)); if (str1 != str2) - warn(("Unsimplified code in test case. It looks like this test " - "should either be cleaned up or moved to TestTokenizer or " - "TestSimplifyTokens instead.\nstr1="+str1+"\nstr2="+str2).c_str()); - + warnUnsimplified(str1, str2); // Check auto variables checkAutoVariables.autoVariables(); diff --git a/test/testboost.cpp b/test/testboost.cpp index f869d12a769..e7b1cbbbbfb 100644 --- a/test/testboost.cpp +++ b/test/testboost.cpp @@ -51,7 +51,7 @@ class TestBoost : public TestFixture { tokenizer.simplifyTokenList2(); const std::string str2(tokenizer.tokens()->stringifyList(0,true)); if (str1 != str2) - warn("Unsimplified code in test case"); + warnUnsimplified(str1, str2); // Check.. CheckBoost checkBoost; diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index dbc3e6daee3..7709dd15e35 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -59,9 +59,7 @@ class TestBufferOverrun : public TestFixture { // Ensure that the test case is not bad. if (verify && str1 != str2) { - warn(("Unsimplified code in test case. It looks like this test " - "should either be cleaned up or moved to TestTokenizer or " - "TestSimplifyTokens instead.\nstr1="+str1+"\nstr2="+str2).c_str()); + warnUnsimplified(str1, str2); } // Check for buffer overruns.. diff --git a/test/testclass.cpp b/test/testclass.cpp index 7538a87e76b..60688f4ab5b 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -2628,7 +2628,7 @@ class TestClass : public TestFixture { tokenizer.simplifyTokenList2(); const std::string str2(tokenizer.tokens()->stringifyList(0,true)); if (verify && str1 != str2) - warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str()); + warnUnsimplified(str1, str2); CheckClass checkClass(&tokenizer, &settings, this); checkClass.checkConst(); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 988c243076d..bee2374fd34 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -84,9 +84,7 @@ class TestCondition : public TestFixture { // Ensure that the test case is not bad. if (validate && str1 != str2) { - warn(("Unsimplified code in test case. It looks like this test " - "should either be cleaned up or moved to TestTokenizer or " - "TestSimplifyTokens instead.\nstr1="+str1+"\nstr2="+str2).c_str()); + warnUnsimplified(str1, str2); } } diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 7e74d0b01c7..c0bf7bbc808 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -115,9 +115,7 @@ class TestNullPointer : public TestFixture { tokenizer.simplifyTokenList2(); const std::string str2(tokenizer.tokens()->stringifyList(0,true)); if (verify && str1 != str2) - warn(("Unsimplified code in test case. It looks like this test " - "should either be cleaned up or moved to TestTokenizer or " - "TestSimplifyTokens instead.\nstr1="+str1+"\nstr2="+str2).c_str()); + warnUnsimplified(str1, str2); checkNullPointer.nullConstantDereference(); } diff --git a/test/testother.cpp b/test/testother.cpp index 532df8297b9..ebb6b33ac63 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -210,7 +210,7 @@ class TestOther : public TestFixture { tokenizer.simplifyTokenList2(); const std::string str2(tokenizer.tokens()->stringifyList(0,true)); if (str1 != str2) - warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str()); + warnUnsimplified(str1, str2); checkOther.runSimplifiedChecks(&tokenizer, settings, this); } } diff --git a/test/testsuite.cpp b/test/testsuite.cpp index 75dbba9b3f3..0d61da5cf30 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -250,6 +250,13 @@ void TestFixture::warn(const char msg[]) warnings << "Warning: " << currentTest << " " << msg << std::endl; } +void TestFixture::warnUnsimplified(const std::string& unsimplified, const std::string& simplified) +{ + warn(("Unsimplified code in test case. It looks like this test " + "should either be cleaned up or moved to TestTokenizer or " + "TestSimplifyTokens instead.\nactual=" + unsimplified + "\nexpected=" + simplified).c_str()); +} + void TestFixture::processOptions(const options& args) { quiet_tests = args.quiet(); diff --git a/test/testsuite.h b/test/testsuite.h index cbc6bdb5ad1..779d87fc9ff 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -72,6 +72,7 @@ class TestFixture : public ErrorLogger { virtual void reportErr(const ErrorLogger::ErrorMessage &msg); void run(const std::string &str); void warn(const char msg[]); + void warnUnsimplified(const std::string& unsimplified, const std::string& simplified); TestFixture(const std::string &_name); virtual ~TestFixture() { } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index a1e9b1f20da..b87aa4706cc 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2093,9 +2093,7 @@ class TestUninitVar : public TestFixture { tokenizer.simplifyTokenList2(); const std::string str2(tokenizer.tokens()->stringifyList(0,true)); if (verify && str1 != str2) - warn(("Unsimplified code in test case. It looks like this test " - "should either be cleaned up or moved to TestTokenizer or " - "TestSimplifyTokens instead.\nstr1="+str1+"\nstr2="+str2).c_str()); + warnUnsimplified(str1, str2); // Check for redundant code.. CheckUninitVar checkuninitvar(&tokenizer, &settings1, this);