Refactoring tests. Use utility function to warn about unsimplified code in tests.

This commit is contained in:
Dmitry-Me 2014-09-13 12:59:32 +02:00 committed by Daniel Marjamäki
parent 92bd12a302
commit 1e298a31cf
10 changed files with 16 additions and 19 deletions

View File

@ -57,10 +57,7 @@ private:
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();

View File

@ -51,7 +51,7 @@ private:
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;

View File

@ -59,9 +59,7 @@ private:
// 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..

View File

@ -2628,7 +2628,7 @@ private:
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();

View File

@ -84,9 +84,7 @@ private:
// 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);
}
}

View File

@ -115,9 +115,7 @@ private:
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();
}

View File

@ -210,7 +210,7 @@ private:
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);
}
}

View File

@ -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();

View File

@ -72,6 +72,7 @@ public:
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() { }

View File

@ -2093,9 +2093,7 @@ private:
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);