Fix some warnings (#3096)
This commit is contained in:
parent
c638edc8b4
commit
02ac2b08a0
|
@ -294,7 +294,7 @@ namespace ExprEngine {
|
|||
ValuePtr op1;
|
||||
ValuePtr op2;
|
||||
private:
|
||||
std::string getName(const std::string &binop, ValuePtr op1, ValuePtr op2) const {
|
||||
static std::string getName(const std::string& binop, ValuePtr op1, ValuePtr op2) {
|
||||
std::string name1 = op1 ? op1->name : std::string("null");
|
||||
std::string name2 = op2 ? op2->name : std::string("null");
|
||||
return "(" + name1 + ")" + binop + "(" + name2 + ")";
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace ValueFlow {
|
|||
/** The value bound */
|
||||
enum class Bound { Upper, Lower, Point } bound;
|
||||
|
||||
/** int value */
|
||||
/** int value (or sometimes bool value?) */
|
||||
long long intvalue;
|
||||
|
||||
/** token value - the token that has the value. this is used for pointer aliases, strings, etc. */
|
||||
|
|
|
@ -5297,7 +5297,7 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
unsigned int instantiateMatch(const char code[], const std::size_t numberOfArguments, const char patternAfter[]) {
|
||||
bool instantiateMatch(const char code[], const std::size_t numberOfArguments, const char patternAfter[]) {
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
||||
std::istringstream istr(code);
|
||||
|
|
|
@ -143,18 +143,23 @@ bool TestFixture::assert_(const char * const filename, const unsigned int linenr
|
|||
return condition;
|
||||
}
|
||||
|
||||
void TestFixture::assertEqualsFailed(const char* const filename, const unsigned int linenr, const std::string& expected, const std::string& actual, const std::string& msg) const
|
||||
{
|
||||
++fails_counter;
|
||||
errmsg << getLocationStr(filename, linenr) << ": Assertion failed. " << std::endl
|
||||
<< "Expected: " << std::endl
|
||||
<< writestr(expected) << std::endl
|
||||
<< "Actual: " << std::endl
|
||||
<< writestr(actual) << std::endl;
|
||||
if (!msg.empty())
|
||||
errmsg << "Hint:" << std::endl << msg << std::endl;
|
||||
errmsg << "_____" << std::endl;
|
||||
}
|
||||
|
||||
bool TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const
|
||||
{
|
||||
if (expected != actual) {
|
||||
++fails_counter;
|
||||
errmsg << getLocationStr(filename, linenr) << ": Assertion failed. " << std::endl
|
||||
<< "Expected: " << std::endl
|
||||
<< writestr(expected) << std::endl
|
||||
<< "Actual: " << std::endl
|
||||
<< writestr(actual) << std::endl;
|
||||
if (!msg.empty())
|
||||
errmsg << "Hint:" << std::endl << msg << std::endl;
|
||||
errmsg << "_____" << std::endl;
|
||||
assertEqualsFailed(filename, linenr, expected, actual, msg);
|
||||
}
|
||||
return expected == actual;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,23 @@ protected:
|
|||
|
||||
bool assert_(const char * const filename, const unsigned int linenr, const bool condition) const;
|
||||
|
||||
template <typename T, typename U>
|
||||
bool assertEquals(const char* const filename, const unsigned int linenr, const T& expected, const U& actual, const std::string& msg = emptyString) const {
|
||||
if (expected != actual) {
|
||||
std::ostringstream expectedStr;
|
||||
expectedStr << expected;
|
||||
std::ostringstream actualStr;
|
||||
actualStr << actual;
|
||||
|
||||
assertEqualsFailed(filename, linenr, expectedStr.str(), actualStr.str(), msg);
|
||||
}
|
||||
return expected == actual;
|
||||
}
|
||||
|
||||
//Helper function to be called when an assertEquals assertion fails.
|
||||
//Writes the appropriate failure message to errmsg and increments fails_counter
|
||||
void assertEqualsFailed(const char* const filename, const unsigned int linenr, const std::string& expected, const std::string& actual, const std::string& msg) const;
|
||||
|
||||
bool assertEquals(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
|
||||
void assertEqualsWithoutLineNumbers(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
|
||||
bool assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const;
|
||||
|
|
|
@ -3103,7 +3103,7 @@ private:
|
|||
values = tokenValues(code, "<");
|
||||
ASSERT_EQUALS(1, values.size());
|
||||
ASSERT(values.front().isPossible());
|
||||
ASSERT_EQUALS(true, values.front().intvalue);
|
||||
ASSERT_EQUALS(1, values.front().intvalue);
|
||||
|
||||
code = "void f() {\n"
|
||||
" S s;\n"
|
||||
|
@ -3143,7 +3143,7 @@ private:
|
|||
values = tokenValues(code, ">");
|
||||
ASSERT_EQUALS(1, values.size());
|
||||
ASSERT(values.front().isPossible());
|
||||
ASSERT_EQUALS(true, values.front().intvalue);
|
||||
ASSERT_EQUALS(1, values.front().intvalue);
|
||||
|
||||
code = "void foo() {\n"
|
||||
" struct ISO_PVD_s pvd;\n"
|
||||
|
|
Loading…
Reference in New Issue