Fixed VS warnings in testsymboldatabase.cpp

This commit is contained in:
PKEuS 2014-05-25 09:52:54 +02:00
parent d3dbfad131
commit 4f61e9783b
1 changed files with 114 additions and 74 deletions

View File

@ -2245,114 +2245,154 @@ private:
void varTypesIntegral() {
GET_SYMBOL_DB("void f() { bool b; char c; unsigned char uc; short s; unsigned short us; int i; unsigned u; unsigned int ui; long l; unsigned long ul; long long ll; }");
const Variable *b = db->getVariableFromVarId(1);
ASSERT(b);
ASSERT_EQUALS("b", b->nameToken()->str());
ASSERT_EQUALS(true, b->isIntegralType());
ASSERT_EQUALS(false, b->isFloatingType());
ASSERT(b != nullptr);
if (b) {
ASSERT_EQUALS("b", b->nameToken()->str());
ASSERT_EQUALS(true, b->isIntegralType());
ASSERT_EQUALS(false, b->isFloatingType());
}
const Variable *c = db->getVariableFromVarId(2);
ASSERT(c);
ASSERT_EQUALS("c", c->nameToken()->str());
ASSERT_EQUALS(true, c->isIntegralType());
ASSERT_EQUALS(false, c->isFloatingType());
ASSERT(c != nullptr);
if (c) {
ASSERT_EQUALS("c", c->nameToken()->str());
ASSERT_EQUALS(true, c->isIntegralType());
ASSERT_EQUALS(false, c->isFloatingType());
}
const Variable *uc = db->getVariableFromVarId(3);
ASSERT(uc);
ASSERT_EQUALS("uc", uc->nameToken()->str());
ASSERT_EQUALS(true, uc->isIntegralType());
ASSERT_EQUALS(false, uc->isFloatingType());
ASSERT(uc != nullptr);
if (uc) {
ASSERT_EQUALS("uc", uc->nameToken()->str());
ASSERT_EQUALS(true, uc->isIntegralType());
ASSERT_EQUALS(false, uc->isFloatingType());
}
const Variable *s = db->getVariableFromVarId(4);
ASSERT(s);
ASSERT_EQUALS("s", s->nameToken()->str());
ASSERT_EQUALS(true, s->isIntegralType());
ASSERT_EQUALS(false, s->isFloatingType());
ASSERT(s != nullptr);
if (s) {
ASSERT_EQUALS("s", s->nameToken()->str());
ASSERT_EQUALS(true, s->isIntegralType());
ASSERT_EQUALS(false, s->isFloatingType());
}
const Variable *us = db->getVariableFromVarId(5);
ASSERT(us);
ASSERT_EQUALS("us", us->nameToken()->str());
ASSERT_EQUALS(true, us->isIntegralType());
ASSERT_EQUALS(false, us->isFloatingType());
ASSERT(us != nullptr);
if (us) {
ASSERT_EQUALS("us", us->nameToken()->str());
ASSERT_EQUALS(true, us->isIntegralType());
ASSERT_EQUALS(false, us->isFloatingType());
}
const Variable *i = db->getVariableFromVarId(6);
ASSERT(i);
ASSERT_EQUALS("i", i->nameToken()->str());
ASSERT_EQUALS(true, i->isIntegralType());
ASSERT_EQUALS(false, i->isFloatingType());
ASSERT(i != nullptr);
if (i) {
ASSERT_EQUALS("i", i->nameToken()->str());
ASSERT_EQUALS(true, i->isIntegralType());
ASSERT_EQUALS(false, i->isFloatingType());
}
const Variable *u = db->getVariableFromVarId(7);
ASSERT(u);
ASSERT_EQUALS("u", u->nameToken()->str());
ASSERT_EQUALS(true, u->isIntegralType());
ASSERT_EQUALS(false, u->isFloatingType());
ASSERT(u != nullptr);
if (u) {
ASSERT_EQUALS("u", u->nameToken()->str());
ASSERT_EQUALS(true, u->isIntegralType());
ASSERT_EQUALS(false, u->isFloatingType());
}
const Variable *ui = db->getVariableFromVarId(8);
ASSERT(ui);
ASSERT_EQUALS("ui", ui->nameToken()->str());
ASSERT_EQUALS(true, ui->isIntegralType());
ASSERT_EQUALS(false, ui->isFloatingType());
ASSERT(ui != nullptr);
if (ui) {
ASSERT_EQUALS("ui", ui->nameToken()->str());
ASSERT_EQUALS(true, ui->isIntegralType());
ASSERT_EQUALS(false, ui->isFloatingType());
}
const Variable *l = db->getVariableFromVarId(9);
ASSERT(l);
ASSERT_EQUALS("l", l->nameToken()->str());
ASSERT_EQUALS(true, l->isIntegralType());
ASSERT_EQUALS(false, l->isFloatingType());
ASSERT(l != nullptr);
if (l) {
ASSERT_EQUALS("l", l->nameToken()->str());
ASSERT_EQUALS(true, l->isIntegralType());
ASSERT_EQUALS(false, l->isFloatingType());
}
const Variable *ul = db->getVariableFromVarId(10);
ASSERT(ul);
ASSERT_EQUALS("ul", ul->nameToken()->str());
ASSERT_EQUALS(true, ul->isIntegralType());
ASSERT_EQUALS(false, ul->isFloatingType());
ASSERT(ul != nullptr);
if (ul) {
ASSERT_EQUALS("ul", ul->nameToken()->str());
ASSERT_EQUALS(true, ul->isIntegralType());
ASSERT_EQUALS(false, ul->isFloatingType());
}
const Variable *ll = db->getVariableFromVarId(11);
ASSERT(ui);
ASSERT_EQUALS("ll", ll->nameToken()->str());
ASSERT_EQUALS(true, ll->isIntegralType());
ASSERT_EQUALS(false, ll->isFloatingType());
ASSERT(ui != nullptr);
if (ui) {
ASSERT_EQUALS("ll", ll->nameToken()->str());
ASSERT_EQUALS(true, ll->isIntegralType());
ASSERT_EQUALS(false, ll->isFloatingType());
}
}
void varTypesFloating() {
{
GET_SYMBOL_DB("void f() { float f; double d; long double ld; }");
const Variable *f = db->getVariableFromVarId(1);
ASSERT(f);
ASSERT_EQUALS("f", f->nameToken()->str());
ASSERT_EQUALS(false, f->isIntegralType());
ASSERT_EQUALS(true, f->isFloatingType());
ASSERT(f != nullptr);
if (f) {
ASSERT_EQUALS("f", f->nameToken()->str());
ASSERT_EQUALS(false, f->isIntegralType());
ASSERT_EQUALS(true, f->isFloatingType());
}
const Variable *d = db->getVariableFromVarId(2);
ASSERT(d);
ASSERT_EQUALS("d", d->nameToken()->str());
ASSERT_EQUALS(false, d->isIntegralType());
ASSERT_EQUALS(true, d->isFloatingType());
ASSERT(d != nullptr);
if (d) {
ASSERT_EQUALS("d", d->nameToken()->str());
ASSERT_EQUALS(false, d->isIntegralType());
ASSERT_EQUALS(true, d->isFloatingType());
}
const Variable *ld = db->getVariableFromVarId(3);
ASSERT(ld);
ASSERT_EQUALS("ld", ld->nameToken()->str());
ASSERT_EQUALS(false, ld->isIntegralType());
ASSERT_EQUALS(true, ld->isFloatingType());
ASSERT(ld != nullptr);
if (ld) {
ASSERT_EQUALS("ld", ld->nameToken()->str());
ASSERT_EQUALS(false, ld->isIntegralType());
ASSERT_EQUALS(true, ld->isFloatingType());
}
}
{
GET_SYMBOL_DB("void f() { float * f; static const float * scf; }");
const Variable *f = db->getVariableFromVarId(1);
ASSERT(f);
ASSERT_EQUALS("f", f->nameToken()->str());
ASSERT_EQUALS(false, f->isIntegralType());
ASSERT_EQUALS(false, f->isFloatingType());
ASSERT(f != nullptr);
if (f) {
ASSERT_EQUALS("f", f->nameToken()->str());
ASSERT_EQUALS(false, f->isIntegralType());
ASSERT_EQUALS(false, f->isFloatingType());
}
const Variable *scf = db->getVariableFromVarId(2);
ASSERT(scf);
ASSERT_EQUALS("scf", scf->nameToken()->str());
ASSERT_EQUALS(false, scf->isIntegralType());
ASSERT_EQUALS(false, scf->isFloatingType());
ASSERT(scf != nullptr);
if (scf) {
ASSERT_EQUALS("scf", scf->nameToken()->str());
ASSERT_EQUALS(false, scf->isIntegralType());
ASSERT_EQUALS(false, scf->isFloatingType());
}
}
{
GET_SYMBOL_DB("void f() { float fa[42]; }");
const Variable *fa = db->getVariableFromVarId(1);
ASSERT(fa);
ASSERT_EQUALS("fa", fa->nameToken()->str());
ASSERT_EQUALS(false, fa->isIntegralType());
ASSERT_EQUALS(false, fa->isFloatingType());
ASSERT(fa != nullptr);
if (fa) {
ASSERT_EQUALS("fa", fa->nameToken()->str());
ASSERT_EQUALS(false, fa->isIntegralType());
ASSERT_EQUALS(false, fa->isFloatingType());
}
}
}
void varTypesOther() {
GET_SYMBOL_DB("void f() { class A {} a; void *b; }");
const Variable *a = db->getVariableFromVarId(1);
ASSERT_EQUALS("a", a->nameToken()->str());
ASSERT_EQUALS(false, a->isIntegralType());
ASSERT_EQUALS(false, a->isFloatingType());
ASSERT(a != nullptr);
if (a) {
ASSERT_EQUALS("a", a->nameToken()->str());
ASSERT_EQUALS(false, a->isIntegralType());
ASSERT_EQUALS(false, a->isFloatingType());
}
const Variable *b = db->getVariableFromVarId(2);
ASSERT_EQUALS("b", b->nameToken()->str());
ASSERT_EQUALS(false, b->isIntegralType());
ASSERT_EQUALS(false, b->isFloatingType());
ASSERT(b != nullptr);
if (b) {
ASSERT_EQUALS("b", b->nameToken()->str());
ASSERT_EQUALS(false, b->isIntegralType());
ASSERT_EQUALS(false, b->isFloatingType());
}
}
};