aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-28 17:42:24 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:06 -0300
commit068900d4f0af107e03dca9b530fff47deac4066d (patch)
tree4e2da52e5fe5d5860f745b027f78f400f489c89e /tests
parent28401810fe9be0dafea604a50b4139d10f75873a (diff)
Added test for template inheritance involving a forward declaration.
When things goes awry methods from the template parent class got duplicated in the inheriting class.
Diffstat (limited to 'tests')
-rw-r--r--tests/testtemplates.cpp32
-rw-r--r--tests/testtemplates.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/testtemplates.cpp b/tests/testtemplates.cpp
index 19bc32eca..97738fda7 100644
--- a/tests/testtemplates.cpp
+++ b/tests/testtemplates.cpp
@@ -110,6 +110,38 @@ void TestTemplates::testTemplateOnContainers()
QCOMPARE(instance2->typeEntry()->qualifiedCppName(), QString("Namespace::E1"));
}
+void TestTemplates::testTemplateInheritanceMixedWithForwardDeclaration()
+{
+ const char cppCode[] = "\
+ enum SomeEnum { E1, E2 };\
+ template<SomeEnum type> struct Future;\
+ template<SomeEnum type>\
+ struct A {\
+ A();\
+ void method();\
+ friend struct Future<type>;\
+ };\
+ typedef A<E1> B;\
+ template<SomeEnum type> struct Future {};\
+ ";
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\
+ <enum-type name='SomeEnum' />\
+ <value-type name='A' generate='no' />\
+ <value-type name='B' />\
+ <value-type name='Future' generate='no' />\
+ </typesystem>";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaClassList classes = t.builder()->classes();
+
+ AbstractMetaClass* classB = classes.findClass("B");
+ QVERIFY(!classB->baseClass());
+ QVERIFY(classB->baseClassName().isNull());
+ // 3 functions: simple constructor, copy constructor and "method()".
+ QCOMPARE(classB->functions().count(), 3);
+}
+
QTEST_APPLESS_MAIN(TestTemplates)
#include "testtemplates.moc"
diff --git a/tests/testtemplates.h b/tests/testtemplates.h
index b04002a75..430a7599c 100644
--- a/tests/testtemplates.h
+++ b/tests/testtemplates.h
@@ -32,6 +32,7 @@ class TestTemplates : public QObject
private slots:
void testTemplateOnContainers();
void testTemplateWithNamespace();
+ void testTemplateInheritanceMixedWithForwardDeclaration();
};
#endif