Skip to content
Snippets Groups Projects
Commit 98cc3ec6 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

More testing of typedefs.

parent ccd05bd8
No related branches found
No related tags found
No related merge requests found
......@@ -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"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment