diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-07-28 14:43:23 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:05 -0300 |
commit | 1eee074d77f6c612a7644aea7b17d7a0128806cc (patch) | |
tree | 7d673533d34644e66852eed3660dfd914052acfa /tests | |
parent | 454efd2e01c06832bedc89a93e139dd6f011a296 (diff) |
Fixed writeBaseConversion method to handle references to C++ primitives.
Added test for a reference to integer as a function argument.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libsample/functions.cpp | 11 | ||||
-rw-r--r-- | tests/libsample/functions.h | 5 | ||||
-rw-r--r-- | tests/samplebinding/primitivereferenceargument_test.py | 44 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 2 |
4 files changed, 61 insertions, 1 deletions
diff --git a/tests/libsample/functions.cpp b/tests/libsample/functions.cpp index 8cd77351b..9a0bf2e0e 100644 --- a/tests/libsample/functions.cpp +++ b/tests/libsample/functions.cpp @@ -167,3 +167,14 @@ acceptDouble(double x) return x; } +int +acceptIntReference(int& x) +{ + return x; +} + +OddBool +acceptOddBoolReference(OddBool& x) +{ + return x; +} diff --git a/tests/libsample/functions.h b/tests/libsample/functions.h index 02256e033..848777e19 100644 --- a/tests/libsample/functions.h +++ b/tests/libsample/functions.h @@ -26,6 +26,7 @@ #include "libsamplemacros.h" #include <list> #include <utility> +#include "oddbool.h" #include "complex.h" #include "objecttype.h" @@ -69,5 +70,7 @@ LIBSAMPLE_API long acceptLong(long x); LIBSAMPLE_API unsigned long acceptULong(unsigned long x); LIBSAMPLE_API double acceptDouble(double x); -#endif // FUNCTIONS_H +LIBSAMPLE_API int acceptIntReference(int& x); +LIBSAMPLE_API OddBool acceptOddBoolReference(OddBool& x); +#endif // FUNCTIONS_H diff --git a/tests/samplebinding/primitivereferenceargument_test.py b/tests/samplebinding/primitivereferenceargument_test.py new file mode 100644 index 000000000..58299fea5 --- /dev/null +++ b/tests/samplebinding/primitivereferenceargument_test.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# This file is part of the Shiboken Python Bindings Generator project. +# +# Copyright (C) 2011 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 Lesser General Public License +# version 2.1 as published by the Free Software Foundation. Please +# review the following information to ensure the GNU Lesser General +# Public License version 2.1 requirements will be met: +# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# # +# 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser 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 + +import unittest +import sample + +class PrimitiveReferenceArgumentTest(unittest.TestCase): + + def testIntReferenceArgument(self): + '''C++ signature: int acceptIntReference(int&)''' + self.assertEqual(sample.acceptIntReference(123), 123) + + def testOddBoolReferenceArgument(self): + '''C++ signature: OddBool acceptOddBoolReference(OddBool&)''' + self.assertEqual(sample.acceptOddBoolReference(True), True) + self.assertEqual(sample.acceptOddBoolReference(False), False) + self.assertNotEqual(sample.acceptOddBoolReference(True), False) + self.assertNotEqual(sample.acceptOddBoolReference(False), True) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index b02283395..aa5ca9885 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -75,6 +75,8 @@ <function signature="acceptLong(long)" /> <function signature="acceptULong(unsigned long)" /> <function signature="acceptDouble(double)" /> + <function signature="acceptIntReference(int&)" /> + <function signature="acceptOddBoolReference(OddBool&)" /> <function signature="countCharacters(const char*)" /> <function signature="gimmeInt()" /> <function signature="gimmeDouble()" /> |