diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2010-02-02 16:54:04 -0200 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-02-02 16:54:04 -0200 |
commit | 1b3edf359d122cc36378df6ec905e07a77bd8580 (patch) | |
tree | e0a83c6a17cd0840fb8d82384a8357576b9f6135 /tests/testmodifyfunction.cpp | |
parent | 4a14c6632f6a4245a20bd46cb94f9d807188276d (diff) |
Added tests for ownership modification.
Diffstat (limited to 'tests/testmodifyfunction.cpp')
-rw-r--r-- | tests/testmodifyfunction.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
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" |