summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-30 16:08:24 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:06 -0300
commitfff2628c407b0e53bab6b47bcb82621f37111c0b (patch)
tree57c607969b20cf0220b491741eaedb8e5fa45e06
parentd3435da2648113d21fa85dc93b5b4f65a80f1731 (diff)
Added test for a class inheriting from a container template.
The test is simple and only checks if the classes were inherited properly.
-rw-r--r--tests/testtemplates.cpp36
-rw-r--r--tests/testtemplates.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/testtemplates.cpp b/tests/testtemplates.cpp
index 2eb66acb..d0ea40e3 100644
--- a/tests/testtemplates.cpp
+++ b/tests/testtemplates.cpp
@@ -110,6 +110,42 @@ void TestTemplates::testTemplateOnContainers()
QCOMPARE(instance2->typeEntry()->qualifiedCppName(), QString("Namespace::E1"));
}
+void TestTemplates::testInheritanceFromContainterTemplate()
+{
+ const char cppCode[] = "\
+ template<typename T>\
+ struct ListContainer {\
+ inline void push_front(const T& t);\
+ inline T& front();\
+ };\
+ struct FooBar {};\
+ struct FooBars : public ListContainer<FooBar> {};\
+ ";
+
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\
+ <container-type name='ListContainer' type='list' /> \
+ <value-type name='FooBar' />\
+ <value-type name='FooBars'>\
+ <modify-function signature='push_front(FooBar)' remove='all' />\
+ <modify-function signature='front()' remove='all' />\
+ </value-type>\
+ </typesystem>\
+ ";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaClassList classes = t.builder()->classes();
+ AbstractMetaClassList templates = t.builder()->templates();
+ QCOMPARE(classes.count(), 2);
+ QCOMPARE(templates.count(), 1);
+
+ const AbstractMetaClass* foobars = classes.findClass("FooBars");
+ QCOMPARE(foobars->functions().count(), 4);
+
+ const AbstractMetaClass* lc = templates.first();
+ QCOMPARE(lc->functions().count(), 2);
+}
+
void TestTemplates::testTemplateInheritanceMixedWithForwardDeclaration()
{
const char cppCode[] = "\
diff --git a/tests/testtemplates.h b/tests/testtemplates.h
index a7a61c79..df75db1d 100644
--- a/tests/testtemplates.h
+++ b/tests/testtemplates.h
@@ -32,6 +32,7 @@ class TestTemplates : public QObject
private slots:
void testTemplateOnContainers();
void testTemplateWithNamespace();
+ void testInheritanceFromContainterTemplate();
void testTemplateInheritanceMixedWithForwardDeclaration();
void testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration();
};