SymbolDatabase: Add test that makes sure enum constant values are calculated properly. Related with ticket #7493.

This commit is contained in:
Daniel Marjamäki 2016-05-12 12:06:14 +02:00
parent 613311cc57
commit df6a66deed
1 changed files with 29 additions and 0 deletions

View File

@ -245,6 +245,7 @@ private:
TEST_CASE(enum1);
TEST_CASE(enum2);
TEST_CASE(enum3);
TEST_CASE(enum4);
TEST_CASE(isImplicitlyVirtual);
TEST_CASE(isPure);
@ -2293,6 +2294,34 @@ private:
}
}
void enum4() { // #7493
GET_SYMBOL_DB("enum Offsets { O1, O2, O3 };\n"
"enum MyEnums { E1=O1+1, E2=O2+1, E3=O3+1 };");
ASSERT(db);
if (!db)
return;
ASSERT_EQUALS(3U, db->scopeList.size());
// Assert that all enum values are known
std::list<Scope>::const_iterator scope = db->scopeList.begin();
// Offsets
++scope;
ASSERT_EQUALS((unsigned int)Scope::eEnum, (unsigned int)scope->type);
ASSERT_EQUALS(3U, scope->enumeratorList.size());
ASSERT_EQUALS(true, scope->enumeratorList[0].value_known);
ASSERT_EQUALS(true, scope->enumeratorList[1].value_known);
ASSERT_EQUALS(true, scope->enumeratorList[2].value_known);
// MyEnums
++scope;
ASSERT_EQUALS((unsigned int)Scope::eEnum, (unsigned int)scope->type);
ASSERT_EQUALS(3U, scope->enumeratorList.size());
TODO_ASSERT_EQUALS(true, false, scope->enumeratorList[0].value_known);
TODO_ASSERT_EQUALS(true, false, scope->enumeratorList[1].value_known);
TODO_ASSERT_EQUALS(true, false, scope->enumeratorList[2].value_known);
}
void isImplicitlyVirtual() {
{
GET_SYMBOL_DB("class Base {\n"