diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-09-01 18:53:22 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:19 -0300 |
commit | e7fdca6465740132bd881ffd9d20e61be47472d0 (patch) | |
tree | 00b4b44348d9389e4e394d08b99b11478f88d63c /tests | |
parent | 2d3a55bd847616a9b666531795d3b99e5c78a56a (diff) |
Fixes method's argument types that are templates but the template variable wasn't declared.
An unit test was added.
Other unrelated tests had minor improvements.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testcontainer.cpp | 2 | ||||
-rw-r--r-- | tests/testenum.cpp | 4 | ||||
-rw-r--r-- | tests/testrefcounttag.cpp | 4 | ||||
-rw-r--r-- | tests/testtemplates.cpp | 41 | ||||
-rw-r--r-- | tests/testtemplates.h | 1 |
5 files changed, 47 insertions, 5 deletions
diff --git a/tests/testcontainer.cpp b/tests/testcontainer.cpp index 1f5af51fa..563b75c20 100644 --- a/tests/testcontainer.cpp +++ b/tests/testcontainer.cpp @@ -54,8 +54,6 @@ void TestContainer::testContainerType() QCOMPARE(reinterpret_cast<const ContainerTypeEntry*>(classA->typeEntry()->baseContainerType())->type(), ContainerTypeEntry::ListContainer); } - - QTEST_APPLESS_MAIN(TestContainer) #include "testcontainer.moc" diff --git a/tests/testenum.cpp b/tests/testenum.cpp index 07aa0e8cb..85796a1e9 100644 --- a/tests/testenum.cpp +++ b/tests/testenum.cpp @@ -62,7 +62,9 @@ void TestEnum::testEnumCppSignature() // enum as parameter of a method AbstractMetaClass* classA = classes.findClass("A"); QCOMPARE(classA->enums().count(), 1); - AbstractMetaFunction* method = classA->queryFunctionsByName("method").first(); + AbstractMetaFunctionList funcs = classA->queryFunctionsByName("method"); + QVERIFY(!funcs.isEmpty()); + AbstractMetaFunction* method = funcs.first(); QVERIFY(method); AbstractMetaArgument* arg = method->arguments().first(); QCOMPARE(arg->type()->name(), QString("ClassEnum")); diff --git a/tests/testrefcounttag.cpp b/tests/testrefcounttag.cpp index 424055f2c..9e05cee93 100644 --- a/tests/testrefcounttag.cpp +++ b/tests/testrefcounttag.cpp @@ -48,7 +48,7 @@ void TestRefCountTag::testReferenceCountTag() AbstractMetaClassList classes = t.builder()->classes(); AbstractMetaClass* classB = classes.findClass("B"); const AbstractMetaFunction* func = classB->findFunction("keepObject"); - + QVERIFY(func); ReferenceCount refCount = func->modifications().first().argument_mods.first().referenceCounts.first(); QCOMPARE(refCount.action, ReferenceCount::Add); } @@ -80,7 +80,7 @@ void TestRefCountTag::testWithApiVersion() AbstractMetaClassList classes = t.builder()->classes(); AbstractMetaClass* classB = classes.findClass("B"); const AbstractMetaFunction* func = classB->findFunction("keepObject"); - + QVERIFY(func); ReferenceCount refCount = func->modifications().first().argument_mods.first().referenceCounts.first(); QCOMPARE(refCount.action, ReferenceCount::Add); diff --git a/tests/testtemplates.cpp b/tests/testtemplates.cpp index bfee774d6..c6a65d888 100644 --- a/tests/testtemplates.cpp +++ b/tests/testtemplates.cpp @@ -337,6 +337,47 @@ void TestTemplates::testTypedefOfInstantiationOfTemplateClass() QCOMPARE(inst->cppSignature(), QString("NSpace::TypeOne")); } +void TestTemplates::testContainerTypeIncompleteArgument() +{ + const char* cppCode ="\ + template<typename T>\ + class Vector {\ + void method(const Vector& vector);\ + Vector otherMethod();\ + };\ + template <typename T>\ + void Vector<T>::method(const Vector<T>& vector) {}\ + Vector Vector<T>::otherMethod() { return Vector<T>(); }\ + typedef Vector<int> IntVector;\ + "; + const char* xmlCode = "\ + <typesystem package='Foo'>\ + <primitive-type name='int'/>\ + <container-type name='Vector' type='vector'/>\ + <value-type name='IntVector'/>\ + </typesystem>"; + + TestUtil t(cppCode, xmlCode, true); + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.count(), 1); + + AbstractMetaClass* vector = classes.findClass("IntVector"); + QVERIFY(vector); + QVERIFY(vector->typeEntry()->baseContainerType()); + QCOMPARE(reinterpret_cast<const ContainerTypeEntry*>(vector->typeEntry()->baseContainerType())->type(), ContainerTypeEntry::VectorContainer); + QCOMPARE(vector->functions().count(), 4); + + const AbstractMetaFunction* method = vector->findFunction("method"); + QVERIFY(method); + QCOMPARE(method->signature(), QString("method(const Vector<int > & vector)")); + + const AbstractMetaFunction* otherMethod = vector->findFunction("otherMethod"); + QVERIFY(otherMethod); + QCOMPARE(otherMethod->signature(), QString("otherMethod()")); + QVERIFY(otherMethod->type()); + QCOMPARE(otherMethod->type()->cppSignature(), QString("Vector<int >")); +} + QTEST_APPLESS_MAIN(TestTemplates) #include "testtemplates.moc" diff --git a/tests/testtemplates.h b/tests/testtemplates.h index 1b7267af4..578691169 100644 --- a/tests/testtemplates.h +++ b/tests/testtemplates.h @@ -39,6 +39,7 @@ private slots: void testTemplateInheritanceMixedWithForwardDeclaration(); void testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration(); void testTypedefOfInstantiationOfTemplateClass(); + void testContainerTypeIncompleteArgument(); }; #endif |