SymbolDatabase: Added unit test that ensure the dimension is 0 when it is unknown (#3964)

This commit is contained in:
Daniel Marjamäki 2012-08-10 11:01:12 +02:00
parent b50a36e3f9
commit 9f6a11f89c
1 changed files with 13 additions and 0 deletions

View File

@ -62,6 +62,8 @@ private:
}
void run() {
TEST_CASE(array);
TEST_CASE(test_isVariableDeclarationCanHandleNull);
TEST_CASE(test_isVariableDeclarationIdentifiesSimpleDeclaration);
TEST_CASE(test_isVariableDeclarationIdentifiesScopedDeclaration);
@ -153,6 +155,17 @@ private:
TEST_CASE(isImplicitlyVirtual);
}
void array() {
std::istringstream code("int a[10+2];");
TokenList list(NULL);
list.createTokens(code, "test.c");
list.front()->tokAt(2)->link(list.front()->tokAt(6));
Variable v(list.front()->next(), list.front(), list.back(), 0, Public, NULL, NULL);
ASSERT(v.isArray());
ASSERT_EQUALS(1U, v.dimensions().size());
ASSERT_EQUALS(0U, v.dimension(0));
}
void test_isVariableDeclarationCanHandleNull() {
reset();
bool result = si.isVariableDeclaration(NULL, vartok, typetok);