Improved detection of array dimensions (#6430)

This commit is contained in:
PKEuS 2015-01-31 13:12:06 +01:00
parent f771a79738
commit 27924d4ae2
2 changed files with 9 additions and 7 deletions

View File

@ -1985,6 +1985,8 @@ bool Variable::arrayDimensions(const Library* lib)
}
if (dim)
dim = dim->next();
if (dim && dim->str() == ")")
dim = dim->next();
bool arr = false;
while (dim && dim->next() && dim->str() == "[") {

View File

@ -972,16 +972,16 @@ private:
if (db) {
ASSERT_EQUALS(10, db->getVariableListSize() - 1);
ASSERT_EQUALS(true, db->getVariableFromVarId(1) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1);
ASSERT_EQUALS(true, db->getVariableFromVarId(2) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(3) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->dimensions().size() == 0);
ASSERT_EQUALS(true, db->getVariableFromVarId(4) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(5) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(6) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(7) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(8) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(9) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(10) != nullptr);
ASSERT_EQUALS(true, db->getVariableFromVarId(6) && db->getVariableFromVarId(6)->dimensions().size() == 1);
ASSERT_EQUALS(true, db->getVariableFromVarId(7) && db->getVariableFromVarId(7)->dimensions().size() == 1);
ASSERT_EQUALS(true, db->getVariableFromVarId(8) && db->getVariableFromVarId(8)->dimensions().size() == 1);
ASSERT_EQUALS(true, db->getVariableFromVarId(9) && db->getVariableFromVarId(9)->dimensions().size() == 1);
ASSERT_EQUALS(true, db->getVariableFromVarId(10) && db->getVariableFromVarId(10)->dimensions().size() == 1);
ASSERT_EQUALS("", errout.str());
}
}