Refactoring tests. Use utility function to warn about unsimplified code in tests.
This commit is contained in:
parent
92bd12a302
commit
1e298a31cf
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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..
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue