Test typedefs and pointers to anonymous structs.

This commit is contained in:
Roberto Raggi
2008-12-31 10:47:02 +01:00
parent c7b023c0e1
commit c7ac64e7de
@@ -97,6 +97,7 @@ private slots:
void nested_class_1();
void typedef_1();
void typedef_2();
void typedef_3();
};
void tst_Semantic::function_declaration_1()
@@ -295,5 +296,28 @@ void tst_Semantic::typedef_2()
QVERIFY(mainFun);
}
void tst_Semantic::typedef_3()
{
QSharedPointer<Document> doc = document(
"typedef struct {\n"
" int x, y;\n"
"} *PointPtr;\n"
);
QCOMPARE(doc->errorCount, 0U);
QCOMPARE(doc->globals->symbolCount(), 2U);
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()->isPointerType());
QCOMPARE(typedefPointDecl->type()->asPointerType()->elementType()->asClass(),
_pointStruct);
}
QTEST_APPLESS_MAIN(tst_Semantic)
#include "tst_semantic.moc"