aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-24 09:23:03 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:15 -0300
commit1e2dc2d50f90f71c13f405b0a2bd82af994f7457 (patch)
tree1a210e68b5f13211494c6bdde7478085c46ac912
parent23e950c9a2c9ac493d539f892c5051f703004d32 (diff)
Added tests for template containers used as arguments for functions.
-rw-r--r--tests/testtemplates.cpp72
-rw-r--r--tests/testtemplates.h3
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/testtemplates.cpp b/tests/testtemplates.cpp
index 4ec55099..cd32ac4a 100644
--- a/tests/testtemplates.cpp
+++ b/tests/testtemplates.cpp
@@ -110,6 +110,78 @@ void TestTemplates::testTemplateOnContainers()
QCOMPARE(instance2->typeEntry()->qualifiedCppName(), QString("Namespace::E1"));
}
+void TestTemplates::testTemplateValueAsArgument()
+{
+ const char cppCode[] = "\
+ template<typename T> struct List() {};\
+ void func(List<int> arg) {}\
+ ";
+
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\
+ <primitive-type name='int' />\
+ <container-type name='List' type='list' />\
+ <function signature='func(List&lt;int&gt;)' />\
+ </typesystem>\
+ ";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaFunctionList globalFuncs = t.builder()->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+
+ AbstractMetaFunction* func = globalFuncs.first();
+ QCOMPARE(func->minimalSignature(), QString("func(List<int>)"));
+ QCOMPARE(func->arguments().first()->type()->cppSignature(), QString("List<int >"));
+}
+
+void TestTemplates::testTemplatePointerAsArgument()
+{
+ const char cppCode[] = "\
+ template<typename T> struct List() {};\
+ void func(List<int>* arg) {}\
+ ";
+
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\
+ <primitive-type name='int' />\
+ <container-type name='List' type='list' />\
+ <function signature='func(List&lt;int&gt;*)' />\
+ </typesystem>\
+ ";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaFunctionList globalFuncs = t.builder()->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+
+ AbstractMetaFunction* func = globalFuncs.first();
+ QCOMPARE(func->minimalSignature(), QString("func(List<int>*)"));
+ QCOMPARE(func->arguments().first()->type()->cppSignature(), QString("List<int > *"));
+}
+
+void TestTemplates::testTemplateReferenceAsArgument()
+{
+ const char cppCode[] = "\
+ template<typename T> struct List() {};\
+ void func(List<int>& arg) {}\
+ ";
+
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\
+ <primitive-type name='int' />\
+ <container-type name='List' type='list' />\
+ <function signature='func(List&lt;int&gt;&amp;)' />\
+ </typesystem>\
+ ";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaFunctionList globalFuncs = t.builder()->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+
+ AbstractMetaFunction* func = globalFuncs.first();
+ QCOMPARE(func->minimalSignature(), QString("func(List<int>&)"));
+ QCOMPARE(func->arguments().first()->type()->cppSignature(), QString("List<int > &"));
+}
+
void TestTemplates::testInheritanceFromContainterTemplate()
{
const char cppCode[] = "\
diff --git a/tests/testtemplates.h b/tests/testtemplates.h
index df75db1d..a06a388b 100644
--- a/tests/testtemplates.h
+++ b/tests/testtemplates.h
@@ -32,6 +32,9 @@ class TestTemplates : public QObject
private slots:
void testTemplateOnContainers();
void testTemplateWithNamespace();
+ void testTemplateValueAsArgument();
+ void testTemplatePointerAsArgument();
+ void testTemplateReferenceAsArgument();
void testInheritanceFromContainterTemplate();
void testTemplateInheritanceMixedWithForwardDeclaration();
void testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration();