aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-02-02 16:54:04 -0200
committerHugo Lima <hugo.lima@openbossa.org>2010-02-02 16:54:04 -0200
commit1b3edf359d122cc36378df6ec905e07a77bd8580 (patch)
treee0a83c6a17cd0840fb8d82384a8357576b9f6135 /tests
parent4a14c6632f6a4245a20bd46cb94f9d807188276d (diff)
Added tests for ownership modification.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/testmodifyfunction.cpp57
-rw-r--r--tests/testmodifyfunction.h36
3 files changed, 94 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8c3a64b7c..ef168991f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,3 +17,4 @@ declare_test(testreverseoperators)
declare_test(testdtorinformation)
declare_test(testremoveimplconv)
declare_test(testmultipleinheritance)
+declare_test(testmodifyfunction)
diff --git a/tests/testmodifyfunction.cpp b/tests/testmodifyfunction.cpp
new file mode 100644
index 000000000..94dbc3d9a
--- /dev/null
+++ b/tests/testmodifyfunction.cpp
@@ -0,0 +1,57 @@
+/*
+* This file is part of the API Extractor project.
+*
+* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+*
+* Contact: PySide team <contact@pyside.org>
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+#include "testmodifyfunction.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+
+void TestModifyFunction::testOwnershipTransfer()
+{
+ const char* cppCode ="\
+ struct A {};\
+ struct B {\
+ virtual A* method();\
+ };\
+ ";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\"> \
+ <object-type name='A' /> \
+ <object-type name='B'> \
+ <modify-function signature='method()'>\
+ <modify-argument index='return'>\
+ <define-ownership owner='c++' /> \
+ </modify-argument>\
+ </modify-function>\
+ </object-type>\
+ </typesystem>";
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaClassList classes = t.builder()->classes();
+ AbstractMetaClass* classB = classes.findClass("B");
+ const AbstractMetaFunction* func = classB->findFunction("method");
+
+ QCOMPARE(func->ownership(func->ownerClass(), TypeSystem::TargetLangCode, 0), TypeSystem::CppOwnership);
+}
+
+QTEST_APPLESS_MAIN(TestModifyFunction)
+
+#include "testmodifyfunction.moc"
diff --git a/tests/testmodifyfunction.h b/tests/testmodifyfunction.h
new file mode 100644
index 000000000..95900cb28
--- /dev/null
+++ b/tests/testmodifyfunction.h
@@ -0,0 +1,36 @@
+/*
+* This file is part of the API Extractor project.
+*
+* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+*
+* Contact: PySide team <contact@pyside.org>
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+#ifndef TESTABSTRACTMETACLASS_H
+#define TESTABSTRACTMETACLASS_H
+
+#include <QObject>
+
+class TestModifyFunction : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testOwnershipTransfer();
+};
+
+#endif