Corrections for non-Microsoft compilers
This commit is contained in:
parent
649a89d308
commit
56e90f95d9
|
@ -285,7 +285,7 @@ bool CheckCondition::isOverlappingCond(const Token * const cond1, const Token *
|
|||
return false;
|
||||
|
||||
// same expressions
|
||||
if (isSameExpression(_tokenizer, cond1,cond2,constFunctions))
|
||||
if (isSameExpression(_tokenizer, cond1,cond2,constFunctions))
|
||||
return true;
|
||||
|
||||
// bitwise overlap for example 'x&7' and 'x==1'
|
||||
|
|
|
@ -95,14 +95,14 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
bool isOverlappingCond(const Token * const cond1, const Token * const cond2, const std::set<std::string> &constFunctions) const;
|
||||
/**
|
||||
* Are two conditions opposite
|
||||
* @param isNot do you want to know if cond1 is !cond2 or if cond1 and cond2 are non-overlapping. true: cond1==!cond2 false: cond1==true => cond2==false
|
||||
* @param cond1 condition1
|
||||
* @param cond2 condition2
|
||||
*/
|
||||
bool isOppositeCond(bool isNot, const Token * const cond1, const Token * const cond2, const std::set<std::string> &constFunctions) const;
|
||||
bool isOverlappingCond(const Token * const cond1, const Token * const cond2, const std::set<std::string> &constFunctions) const;
|
||||
/**
|
||||
* Are two conditions opposite
|
||||
* @param isNot do you want to know if cond1 is !cond2 or if cond1 and cond2 are non-overlapping. true: cond1==!cond2 false: cond1==true => cond2==false
|
||||
* @param cond1 condition1
|
||||
* @param cond2 condition2
|
||||
*/
|
||||
bool isOppositeCond(bool isNot, const Token * const cond1, const Token * const cond2, const std::set<std::string> &constFunctions) const;
|
||||
void assignIfError(const Token *tok1, const Token *tok2, const std::string &condition, bool result);
|
||||
void mismatchingBitAndError(const Token *tok1, const MathLib::bigint num1, const Token *tok2, const MathLib::bigint num2);
|
||||
void badBitmaskCheckError(const Token *tok);
|
||||
|
|
|
@ -83,12 +83,12 @@ bool isSameExpression(const Tokenizer *tokenizer, const Token *tok1, const Token
|
|||
return true;
|
||||
if (tok1 == nullptr || tok2 == nullptr)
|
||||
return false;
|
||||
if (tokenizer->isCPP()) {
|
||||
if (tok1->str() == "." && tok1->astOperand1() && tok1->astOperand1()->str() == "this")
|
||||
tok1 = tok1->astOperand2();
|
||||
if (tok2->str() == "." && tok2->astOperand1() && tok2->astOperand1()->str() == "this")
|
||||
tok2 = tok2->astOperand2();
|
||||
}
|
||||
if (tokenizer->isCPP()) {
|
||||
if (tok1->str() == "." && tok1->astOperand1() && tok1->astOperand1()->str() == "this")
|
||||
tok1 = tok1->astOperand2();
|
||||
if (tok2->str() == "." && tok2->astOperand1() && tok2->astOperand1()->str() == "this")
|
||||
tok2 = tok2->astOperand2();
|
||||
}
|
||||
if (tok1->varId() != tok2->varId() || tok1->str() != tok2->str()) {
|
||||
if ((Token::Match(tok1,"<|>") && Token::Match(tok2,"<|>")) ||
|
||||
(Token::Match(tok1,"<=|>=") && Token::Match(tok2,"<=|>="))) {
|
||||
|
@ -197,13 +197,13 @@ void CheckOther::checkCastIntToCharAndBack()
|
|||
if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) {
|
||||
checkCastIntToCharAndBackError(tok, tok->strAt(2));
|
||||
}
|
||||
} else if (_tokenizer->isCPP() && Token::Match(tok, "EOF %comp% ( %var% = std :: cin . get (") || Token::Match(tok, "EOF %comp% ( %var% = cin . get (")) {
|
||||
} else if (_tokenizer->isCPP() && (Token::Match(tok, "EOF %comp% ( %var% = std :: cin . get (") || Token::Match(tok, "EOF %comp% ( %var% = cin . get ("))) {
|
||||
tok = tok->tokAt(3);
|
||||
const Variable *var = tok->variable();
|
||||
if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) {
|
||||
checkCastIntToCharAndBackError(tok, "cin.get");
|
||||
}
|
||||
} else if (_tokenizer->isCPP() && Token::Match(tok, "%var% = std :: cin . get (") || Token::Match(tok, "%var% = cin . get (")) {
|
||||
} else if (_tokenizer->isCPP() && (Token::Match(tok, "%var% = std :: cin . get (") || Token::Match(tok, "%var% = cin . get ("))) {
|
||||
const Variable *var = tok->variable();
|
||||
if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) {
|
||||
vars[tok->varId()] = "cin.get";
|
||||
|
|
|
@ -265,10 +265,10 @@ private:
|
|||
ASSERT_EQUALS(100 , MathLib::toLongNumber("+10.0E+1"));
|
||||
ASSERT_EQUALS(-1 , MathLib::toLongNumber("-10.0E-1"));
|
||||
|
||||
ASSERT_EQUALS(-8552249625308161526, MathLib::toLongNumber("0x89504e470d0a1a0a"));
|
||||
ASSERT_EQUALS(-8481036456200365558, MathLib::toLongNumber("0x8a4d4e470d0a1a0a"));
|
||||
ASSERT_EQUALS(9894494448401390090, MathLib::toULongNumber("0x89504e470d0a1a0a"));
|
||||
ASSERT_EQUALS(9965707617509186058, MathLib::toULongNumber("0x8a4d4e470d0a1a0a"));
|
||||
ASSERT_EQUALS(-8552249625308161526, MathLib::toLongNumber("0x89504e470d0a1a0a"));
|
||||
ASSERT_EQUALS(-8481036456200365558, MathLib::toLongNumber("0x8a4d4e470d0a1a0a"));
|
||||
ASSERT_EQUALS(9894494448401390090ULL, MathLib::toULongNumber("0x89504e470d0a1a0a"));
|
||||
ASSERT_EQUALS(9965707617509186058ULL, MathLib::toULongNumber("0x8a4d4e470d0a1a0a"));
|
||||
|
||||
// zero input
|
||||
ASSERT_EQUALS(0 , MathLib::toULongNumber("0"));
|
||||
|
@ -286,7 +286,12 @@ private:
|
|||
ASSERT_EQUALS(5U, MathLib::toULongNumber("0b101"));
|
||||
|
||||
// from long long
|
||||
ASSERT_EQUALS(0xFF00000000000000LL, MathLib::toLongNumber("0xFF00000000000000LL"));
|
||||
/*
|
||||
* ASSERT_EQUALS(0xFF00000000000000LL, MathLib::toLongNumber("0xFF00000000000000LL"));
|
||||
* This does not work in a portable way!
|
||||
* While it succeds on 32bit Visual Studio it fails on Linux 64bit because it is greater than 0x7FFFFFFFFFFFFFFF (=LLONG_MAX)
|
||||
*/
|
||||
|
||||
ASSERT_EQUALS(0x0A00000000000000LL, MathLib::toLongNumber("0x0A00000000000000LL"));
|
||||
|
||||
// -----------------
|
||||
|
|
|
@ -156,6 +156,24 @@ void TestFixture::_assertEquals(const char *filename, unsigned int linenr, const
|
|||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, std::string(expected), actual, msg);
|
||||
}
|
||||
|
||||
template<>
|
||||
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, std::string(expected), std::string(actual), msg);
|
||||
}
|
||||
|
||||
template<>
|
||||
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, expected, std::string(actual), msg);
|
||||
}
|
||||
|
||||
void TestFixture::assertEqualsDouble(const char *filename, unsigned int linenr, double expected, double actual, const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, MathLib::toString(expected), MathLib::toString(actual), msg);
|
||||
|
|
|
@ -51,36 +51,13 @@ protected:
|
|||
|
||||
void assert_(const char *filename, unsigned int linenr, bool condition) const;
|
||||
void todoAssert(const char *filename, unsigned int linenr, bool condition) const;
|
||||
void _assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const;
|
||||
void _assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const;
|
||||
|
||||
template <typename E, typename A>
|
||||
void assertEquals(const char *filename, unsigned int linenr, const E expected, const A actual, const std::string &msg = emptyString) const {
|
||||
_assertEquals(filename, linenr, MathLib::toString(expected), MathLib::toString(actual), msg);
|
||||
}
|
||||
template <typename E, typename A>
|
||||
void assertEquals(const char *filename, unsigned int linenr, const E expected, const A actual, const std::string &msg = emptyString) const {
|
||||
_assertEquals(filename, linenr, MathLib::toString(expected), MathLib::toString(actual), msg);
|
||||
}
|
||||
|
||||
template<>
|
||||
void assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, std::string(expected), actual, msg);
|
||||
}
|
||||
template<>
|
||||
void assertEquals(const char *filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, std::string(expected), std::string(actual), msg);
|
||||
}
|
||||
template<>
|
||||
void assertEquals(const char *filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg) const
|
||||
{
|
||||
assertEquals(filename, linenr, expected, std::string(actual), msg);
|
||||
}
|
||||
/*
|
||||
void assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
|
||||
void assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const;
|
||||
void assertEquals(const char *filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg = emptyString) const;
|
||||
void assertEquals(const char *filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = emptyString) const;
|
||||
void assertEquals(const char *filename, unsigned int linenr, long long expected, long long actual, const std::string &msg = emptyString) const;
|
||||
void assertEquals(const char *filename, unsigned int linenr, unsigned long long expected, unsigned long long actual, const std::string &msg = emptyString) const;
|
||||
*/
|
||||
void assertEqualsDouble(const char *filename, unsigned int linenr, double expected, double actual, const std::string &msg = emptyString) const;
|
||||
|
||||
void todoAssertEquals(const char *filename, unsigned int linenr, const std::string &wanted,
|
||||
|
@ -104,6 +81,13 @@ public:
|
|||
static std::size_t runTests(const options& args);
|
||||
};
|
||||
|
||||
template<>
|
||||
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg) const;
|
||||
template<>
|
||||
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg) const;
|
||||
template<>
|
||||
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg) const;
|
||||
|
||||
extern std::ostringstream errout;
|
||||
extern std::ostringstream output;
|
||||
extern std::ostringstream warnings;
|
||||
|
|
Loading…
Reference in New Issue