summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-29 10:36:00 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:06 -0300
commit310cd9c13635c5001bc9f63bdcb79ea93cbfccd5 (patch)
treefe5eed00154c2e2b345bbb41f2eba99f2f1c3926
parent2cf33f010b56520bdefacf5a93e15a580f48e641 (diff)
Added test for template inheritance involving forward declaration and namespace.
This test case is similar to a previous test with forward declaration except that this time everything is inside a namespace. This slightly different situation could trigger problems in a different place on AbstractMetaBuilder.
-rw-r--r--tests/testtemplates.cpp35
-rw-r--r--tests/testtemplates.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/testtemplates.cpp b/tests/testtemplates.cpp
index 97738fda..2eb66acb 100644
--- a/tests/testtemplates.cpp
+++ b/tests/testtemplates.cpp
@@ -142,6 +142,41 @@ void TestTemplates::testTemplateInheritanceMixedWithForwardDeclaration()
QCOMPARE(classB->functions().count(), 3);
}
+void TestTemplates::testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration()
+{
+ const char cppCode[] = "\
+ namespace Namespace {\
+ 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'>\
+ <namespace-type name='Namespace' />\
+ <enum-type name='Namespace::SomeEnum' />\
+ <value-type name='Namespace::A' generate='no' />\
+ <value-type name='Namespace::B' />\
+ <value-type name='Namespace::Future' generate='no' />\
+ </typesystem>";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaClassList classes = t.builder()->classes();
+
+ AbstractMetaClass* classB = classes.findClass("Namespace::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 430a7599..a7a61c79 100644
--- a/tests/testtemplates.h
+++ b/tests/testtemplates.h
@@ -33,6 +33,7 @@ private slots:
void testTemplateOnContainers();
void testTemplateWithNamespace();
void testTemplateInheritanceMixedWithForwardDeclaration();
+ void testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration();
};
#endif