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/testtemplates.cpp | |
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/testtemplates.cpp')
-rw-r--r-- | tests/testtemplates.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
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" |