More testing of typedefs.

This commit is contained in:
Roberto Raggi
2008-12-29 09:44:49 +01:00
parent ccd05bd87e
commit 98cc3ec6c9
@@ -96,6 +96,7 @@ private slots:
void function_definition_1();
void nested_class_1();
void typedef_1();
void typedef_2();
};
void tst_Semantic::function_declaration_1()
@@ -264,5 +265,35 @@ void tst_Semantic::typedef_1()
QVERIFY(mainFun);
}
void tst_Semantic::typedef_2()
{
QSharedPointer<Document> doc = document(
"struct _Point {\n"
" int x, y;\n"
"};\n"
"typedef _Point Point;\n"
"int main() {\n"
" Point pt;\n"
" pt.x = 1;\n"
"}\n"
);
QCOMPARE(doc->errorCount, 0U);
QCOMPARE(doc->globals->symbolCount(), 3U);
Class *_pointStruct= doc->globals->symbolAt(0)->asClass();
QVERIFY(_pointStruct);
QCOMPARE(_pointStruct->memberCount(), 2U);
Declaration *typedefPointDecl = doc->globals->symbolAt(1)->asDeclaration();
QVERIFY(typedefPointDecl);
QVERIFY(typedefPointDecl->isTypedef());
QVERIFY(typedefPointDecl->type()->isNamedType());
QCOMPARE(typedefPointDecl->type()->asNamedType()->name(), _pointStruct->name());
Function *mainFun = doc->globals->symbolAt(2)->asFunction();
QVERIFY(mainFun);
}
QTEST_APPLESS_MAIN(tst_Semantic)
#include "tst_semantic.moc"